tags:

views:

79

answers:

2

I'm using the PowerVR .pod file type for 3d meshes. The pod stores data as an interleaved array of the vertex/normal/UV/vertex_indices, etc, for each mesh in the file.

I'm trying to set up some sort of texture batching to minimize my draw calls, my thinking was that I could combine all the data from the meshes that share a texture into large arrays, and then just set that up before doing one big draw call.

The problem with that method is that I just duplicate all the data that's already read from the .pod file. What I would like to do is to create an array of all the vertex pointers that share a texture and tell openGL to use that array to draw all the verts in one big go, without having to copy all the vertex data into its own array.

Is there some way to do this? Normally you'd use glVertexPointer to set up the vertex array, but this would be something more like glVertexPointerPointer...

+3  A: 

You could look at using a Vertex Buffer Object (VBO) as your "large arrays", this will place the your mesh data in VRAM and you would render it using indexes (read pointers) into the VBOs that you've created.

Vertex Buffer Objects

joshperry
+3  A: 

No, OpenGL does not support double indirections.

With respect to your mesh loading, you have 2 options:

  • allocate your big buffers before loading the meshes, load the meshes inside the big buffers
  • allocate your big buffers after the load, copy the data there, delete the initial mesh data.

Both of these solutions end up with a single copy of the data (and if you follow joshperry's advice -which you should-, that data will be managed by OpenGL rather than yourself)

Bahbar