开发者

OpenGL - Vertex Array inside a VBO and Index & Texture Array outside?

Is it possible to place a set of Vertices into a VBO, but take the Index and Texture coor开发者_C百科d. Arrays from regular memory? If yes, which syntax to use?


Yes, it is possible to do this. But you shouldn't.

The reason to use buffer objects is to improve performance. Doing what you suggest simply reduces the performance you would have gained by properly using buffer objects.

Also, it's a driver path that most drivers don't see very often. Either people use buffer objects for vertex data, or they use client memory arrays. Since it's a road less traveled, you're more likely to encounter driver bugs.

The syntax is just the regular syntax. The gl*Pointer calls use buffer objects or not based on whether a buffer object is bound to GL_ARRAY_BUFFER at the time the gl*Pointer call is made. As such, you can bind a buffer to GL_ARRAY_BUFFER, make a gl*Pointer call with an offset, then bind 0 to GL_ARRAY_BUFFER and make a gl*Pointer call with an actual pointer.

Similarly, the glDraw*Elements* calls use a buffer object if a buffer is bound to GL_ELEMENT_ARRAY_BUFFER. So if you want to use client memory for these functions, bind 0 to that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜