问题描述
我试图理解glVertexAttribPointer
,我注意到它接受的类型比GLSL中具有相同类型的类型更多.因此,要记下到目前为止我所知道的所有内容,我使该图与所有类型都匹配(除了无关紧要的打包类型和我不理解的GL_FIXED
之外).
I'm trying to understand glVertexAttribPointer
, and I noticed that it accepts many more types than those that have an equivalent in GLSL. So to write down everything I know so far, I made this diagram matching all the types (except for the packed ones, which don't matter, and GL_FIXED
, which I don't understand.
蓝色节点表示GLSL中的类型,而黄色节点表示传递给glVertexAttribPointer
的符号常量.
Blue nodes represent the type in GLSL, while yellow nodes represent the symbolic constants passed to glVertexAttribPointer
.
红色节点表示类型之间的某种转换.
Red nodes represent some kind of conversion between types.
每个黄色节点仅直接连接到一个蓝色节点,这似乎是其在GLSL中的主要表示形式,但有些可以转换为其他形式.
Each yellow node is only directly connected to one blue node, what seems to be its main representation in GLSL, but some can be converted to some other form.
所以我想我的问题是:该图中的关系是否正确,并且GL_FIXED
如何适应其中?
So I guess my question is: Are the relationships in this diagram correct, and how does GL_FIXED
fit into it?
推荐答案
否.
您不能通过对glVertexAttribPointer
的调用来提供VS int
,uint
或double
输入变量(或其向量).此功能仅 可以提供float
类型.如果您将此函数与非规范化整数一起使用,则它们将被强制转换为浮点数,就像通过标准强制转换操作一样(255变为255.0f). GL_FIXED
只是另一个浮点表示形式,其中32位整数被视为16.16定点值.自然地,当输入到VS时,它将转换为浮点数.
You cannot feed a VS int
, uint
, or double
input variable (or vectors of these) from a call to glVertexAttribPointer
. This function only feeds float
types. If you use non-normalized integers with this function, then they will be cast to floats as if by a standard cast operation (255 becomes 255.0f). GL_FIXED
is just another floating-point representation, where a 32-bit integer is treated as a 16.16 fixed-point value. Naturally, this will be converted to a floating-point number when fed to the VS.
要提供VS整数,必须使用glVertexAttrib I 指针.要填充double
,必须使用glVertexAttrib L Pointer.
To feed the VS integers, you must use glVertexAttribIPointer. To feed double
s, you must use glVertexAttribLPointer.
bool
类型不能是任何类型的输入变量.
bool
types cannot be input variables of any kind.
这篇关于此图是否适用于OpenGL数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!