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()
{
glGenVertexArraysOES(1, &my_vao);
glBindVertexArrayOES(my_vao);
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 );
glBindVertexArrayOES( 0 );
}
void draw()
{
glBindVertexArrayOES(my_vao);
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, attrib1_data);
glDrawArrays( GL_POINTS, 0, 1 );
}
I want to make sure to bind two attributes as a vertex array buffer:
void draw_ok()
{
glBindVertexArrayOES( 0 );
glBindBuffer( GL_ARRAY_BUFFER, my_buffer_attrib0 );
glVertexAttribPointer( 0, 4, GL_FLOAT, GL_FALSE, 0, 0);
glBindBuffer( GL_ARRAY_BUFFER, 0 );
glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, attrib1_data);
glEnableVertexAttribArray( 0 );
glEnableVertexAttribArray( 1 );
glDrawArrays( GL_POINTS, 0, 1);
}
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: