views:

21

answers:

2

Is there any way to use differently sized buffers for glDrawElements? I somehow want to map vertices to texture coordinates, so that the texture coordinate buffer is able to be actually smaller than the vertex buffer.

Example: vertex buffer has 16 vertices and the texture coordinate buffer has 6 vertices.

vertex_buffer[0] -> texture_coordinates_buffer[0]
vertex_buffer[1] -> texture_coordinates_buffer[1]
vertex_buffer[2] -> texture_coordinates_buffer[2]

vertex_buffer[3] -> texture_coordinates_buffer[3]
vertex_buffer[4] -> texture_coordinates_buffer[1]
vertex_buffer[5] -> texture_coordinates_buffer[2]

...

Thanks for every little hint where to look for what.

A: 

Oh, ok, nevermind. Found the answer (Apparently not possible) here: http://stackoverflow.com/questions/618829/opengl-gldrawelements-with-interleaved-buffers

aldi
A: 

You can't do that in OpenGL (or Direct3D). The number of elements in an attribute array must all be equal, e.g. if you have a VBO made of 64 vertices, you will need to have 64 texcoords, 64 normals, etc.

Only way to have this particular mapping would be to pass the texcoords as extra buffer data and use gl_VertexID to fetch it and resolve your mapping.

See extension texture_buffer_object.

Stringer Bell