在股票的OpenGL ES应用,您可以获得(当你在Xcode中创建一个新的“OpenGL的游戏”),在setupGL
功能,还有:
glEnable(GL_DEPTH_TEST);
//glGenVertexArraysOES( 1, &_vertexArray ) ; // va's 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);
然而,这似乎并不认为顶点正在使用的阵列,(据我所知,顶点数组留在客户端存储器中,而顶点缓冲区停在OpenGL的服务器内存)。
如果您注释掉glBindVertexArrayOES
命令,代码似乎工作完全一样。
是glBindVertexArrayOES
调用此Xcode的样品中多余的?