OES_vertex_array_object and client status

I want the vertex array object in OpenGL ES 2.0 to contain two attributes from different buffers, the second buffer was read from client memory ( glBindBuffer(GL_ARRAY_BUFFER, 0)) But I get a runtime error:

GLuint my_vao;
GLuint my_buffer_attrib0;
GLfloat attrib0_data[] = { 0, 0, 0, 0 };
GLfloat attrib1_data[] =  { 1, 1, 1, 1 };

void init()
{
    // setup vao
    glGenVertexArraysOES(1, &my_vao);
    glBindVertexArrayOES(my_vao);

    // setup attrib0 as a vbo
    glGenBuffers( 1, &my_buffer_attrib0 );
    glBindBuffer(GL_ARRAY_BUFFER, my_buffer_attrib0);
    glBufferData( GL_ARRAY_BUFFER, sizeof(attrib0_data), attrib0_data, GL_STATIC_DRAW );
    glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);

    glEnableVertexAttribArray( 0 );
    glEnableVertexAttribArray( 1 );

    // "end" vao
    glBindVertexArrayOES( 0 );

}

void draw()
{

    glBindVertexArrayOES(my_vao);
    // (now I assume attrib0 is bound to my_buffer_attrib0, 
    //  and attrib1 is not bound. but is this assumption true?)

    // setup attrib1
    glBindBuffer( GL_ARRAY_BUFFER, 0 );
    glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, attrib1_data);

    // draw using attrib0 and attrib1
    glDrawArrays( GL_POINTS, 0, 1 );  // runtime error: Thread1: EXC_BAD_ACCESS (code=2, address=0x0)

}

I want to make sure to bind two attributes as a vertex array buffer:

void draw_ok()
{
    glBindVertexArrayOES( 0 );

    // setup attrib0
    glBindBuffer( GL_ARRAY_BUFFER, my_buffer_attrib0 );
    glVertexAttribPointer( 0, 4, GL_FLOAT, GL_FALSE, 0, 0);

    // setup attrib1
    glBindBuffer( GL_ARRAY_BUFFER, 0 );
    glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, attrib1_data);

    glEnableVertexAttribArray( 0 );
    glEnableVertexAttribArray( 1 );

    // draw using attrib0 and attrib1
    glDrawArrays( GL_POINTS, 0, 1);  // ok
}

Is it possible to link two different buffers in a vertex array object? Is OES_vertex_array_object different from (plain) vertex OpenGL array objects? Also note that I get this error in Xcode running the iOS simulator. These are related links:

+5
source share
4 answers

, :

?

: . OpenGL ES , OpenGL VBO , VAO.

, VAO (, VAO, , , glVertexAttribPointer), VAO, VBOs. GL.

VBOs. , , , VBOs - , - . VBO (GL_DYNAMIC_DRAW GL_STREAM_DRAW) glBuffer(Sub)Data glMapBuffer ( glBufferData(..., NULL); glMapBuffer(GL_WRITE_ONLY)).

+6

:

glBindBuffer( GL_ARRAY_BUFFER, 0 );

draw(). , .

+1

() OES_vertex_array_object. , OES_vertex_array_object , , . , OES_vertex_array_object OpenGL VAO. , . OES_vertex_array_object:

     This extension introduces vertex array objects which encapsulate
     vertex array states on the server side (vertex buffer objects).



     * Should a vertex array object be allowed to encapsulate client
     vertex arrays?

     RESOLVED: No. The OpenGL ES working group agreed that compatibility
     with OpenGL and the ability to to guide developers to more
     performant drawing by enforcing VBO usage were more important than
     the possibility of hurting adoption of VAOs.



     An INVALID_OPERATION error is generated if
     VertexAttribPointer is called while a non-zero vertex array object
     is bound, zero is bound to the <ARRAY_BUFFER> buffer object binding
     point and the pointer argument is not NULL [fn1].
       [fn1: This error makes it impossible to create a vertex array
       object containing client array pointers, while still allowing
       buffer objects to be unbound.]



     And the presently attached vertex array object has the following
     impacts on the draw commands:

       While a non-zero vertex array object is bound, if any enabled
       array buffer binding is zero, when DrawArrays or
       DrawElements is called, the result is undefined.

, EXC_BAD_ACCESS undefined!

+1

All Articles