在iOS 5.1上的现有OpenGL ES应用程序中,它们是否真的使用了声明的顶点数组? [英] In the stock OpenGL ES app on iOS 5.1, are they really using the vertex arrays they declare?

查看:122
本文介绍了在iOS 5.1上的现有OpenGL ES应用程序中,它们是否真的使用了声明的顶点数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在现有的OpenGL ES应用程序中,您获得了(当您使用XCode创建新的"OpenGL游戏"时),在setupGL函数中,有:

In the stock OpenGL ES app you get (when you create a new "OpenGL game" in XCode), in the setupGL function, there is:

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服务器内存中).

However, it doesn't seem that vertex arrays are being used, (far as I know, vertex arrays stay in client memory while vertex buffers are parked on OpenGL server memory).

如果您注释掉glBindVertexArrayOES命令,则代码似乎可以完全相同.

If you comment out the glBindVertexArrayOES commands, the code seems to work exactly the same.

此xCode示例中的glBindVertexArrayOES调用是否多余?

Are the glBindVertexArrayOES calls extraneous in this xCode sample?

推荐答案

您正在将顶点数组与顶点数组对象混淆(术语令人困惑).

You're confusing vertex arrays with Vertex Array Objects (the terminology is confusing).

此语句:(据我所知,顶点数组保留在客户端内存中,而顶点缓冲区则存储在OpenGL服务器内存中)"适用于客户端顶点数组.当您想将顶点缓冲区保持在本地时,可以使用它们代替顶点缓冲区对象",从而提供指向glDrawElements/gl * Pointer的原始内存指针.

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

顶点数组对象是OpenGL构造,其中包含绘制对象所需的所有指针.名称中带有"VertexArray"的任何OpenGL函数都适用于"Vertex Array Objects",而不适用于客户端顶点数组.

Vertex Array Objects on the other hand are an OpenGL construct that contains all of the pointers necessary to draw an object. Any OpenGL function with "VertexArray" in the name applies to "Vertex Array Objects", and not client side vertex arrays.

您可以在此处了解有关VAO的更多信息:

You can read more about VAO here:

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

这篇关于在iOS 5.1上的现有OpenGL ES应用程序中,它们是否真的使用了声明的顶点数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆