Is this diagram for OpenGL data types correct?

柔情痞子 提交于 2020-01-11 06:45:07

问题


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.

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.

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.

So I guess my question is: Are the relationships in this diagram correct, and how does GL_FIXED fit into it?


回答1:


No.

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.

To feed the VS integers, you must use glVertexAttribIPointer. To feed doubles, you must use glVertexAttribLPointer.

bool types cannot be input variables of any kind.



来源:https://stackoverflow.com/questions/39586391/is-this-diagram-for-opengl-data-types-correct

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