Different size of Buffers for Vertex and Texture Coordinates?

南楼画角 提交于 2019-12-12 05:34:20

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/3893911/different-size-of-buffers-for-vertex-and-texture-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!