Fejwin
Fejwin

Reputation: 727

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 coord. Arrays from regular memory? If yes, which syntax to use?

Upvotes: 2

Views: 450

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 473407

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.

Upvotes: 4

Related Questions