顶点和纹理坐标的缓冲区大小不同? [英] Different size of Buffers for Vertex and Texture Coordinates?

查看:171
本文介绍了顶点和纹理坐标的缓冲区大小不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法为glDrawElements使用大小不同的缓冲区?我想以某种方式将顶点映射到纹理坐标,以便纹理坐标缓冲区实际上可以小于顶点缓冲区.

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.

例如:顶点缓冲区有16个顶点,纹理坐标缓冲区有6个顶点.

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.

推荐答案

您不能在OpenGL(或Direct3D)中做到这一点.属性数组中的元素数必须全部相等,例如如果您有一个由64个顶点组成的VBO,则需要具有64个texcoords,64个法线等.

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.

具有这种特殊映射的唯一方法是将texcoords作为额外的缓冲区数据传递,并使用gl_VertexID来获取并解析您的映射.

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.

请参阅扩展名 texture_buffer_object .

这篇关于顶点和纹理坐标的缓冲区大小不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆