In the OpenGL ES app on iOS 5.1, do they really use the vertex arrays that they declare?

In the OpenGL ES application that you get (when you create a new "OpenGL game" in Xcode), the setupGL function has:

 glEnable(GL_DEPTH_TEST); //glGenVertexArraysOES( 1, &_vertexArray ) ; // va are not being used! //glBindVertexArrayOES( _vertexArray ) ; // we comment these out // to no ill effect -- are these calls extraneous? glGenBuffers( 1, &_vertexBuffer ) ; glBindBuffer( GL_ARRAY_BUFFER, _vertexBuffer ) ; glBufferData( GL_ARRAY_BUFFER, sizeof(gCubeVertexData), gCubeVertexData, GL_STATIC_DRAW ) ; glEnableVertexAttribArray(GLKVertexAttribPosition); glVertexAttribPointer(GLKVertexAttribPosition, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(0)); glEnableVertexAttribArray(GLKVertexAttribNormal); glVertexAttribPointer(GLKVertexAttribNormal, 3, GL_FLOAT, GL_FALSE, 24, BUFFER_OFFSET(12)); //glBindVertexArrayOES(0); 

However, it seems that vertex arrays are not used (as far as I know, vertex arrays remain in client memory, and vertex buffers are parked in OpenGL server memory).

If you comment out the glBindVertexArrayOES , the code seems to work the exact same way.

Are glBindVertexArrayOES calls extraneous in this xCode example?

+1
source share
1 answer

You are misleading vertex arrays with vertex array objects (the terminology is confusing).

This statement: "(as far as I know, vertex arrays remain in client memory and vertex buffers are parked in OpenGL server memory)" applies to vertex arrays on the client side. They are used instead of "Vertex Buffer Objects" when you want your vertex buffers to be local, and thus supply a raw memory pointer to glDrawElements / gl * Pointer.

Vertex array objects, on the other hand, are an OpenGL construct that contains all the pointers needed to draw an object. Any OpenGL function named "VertexArray" in the name applies to "vertex array objects", and not to client-side vertex arrays.

Here you can learn more about VAO:

http://www.opengl.org/wiki/Vertex_Specification#Vertex_Array_Object

+1
source

Source: https://habr.com/ru/post/1434220/


All Articles