顶点和纹理坐标的缓冲区大小不同?
有没有办法为 glDrawElements 使用不同大小的缓冲区?我以某种方式想要将顶点映射到纹理坐标,以便纹理坐标缓冲区实际上能够小于顶点缓冲区。
示例:顶点缓冲区有 16 个顶点,纹理坐标缓冲区有 6 个顶点。
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]
...
感谢您提供的每一个小提示,去哪里寻找什么。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法在 OpenGL(或 Direct3D)中执行此操作。属性数组中的元素数量必须全部相等,例如,如果您有一个由 64 个顶点组成的 VBO,则需要有 64 个纹理坐标、64 个法线等。
获得此特定映射的唯一方法是传递纹理坐标作为额外的缓冲区数据并使用
gl_VertexID
来获取它并解析您的映射。请参阅扩展 texture_buffer_object。
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.