openglglslvertex-attributes

Is this diagram for OpenGL data types correct?


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.

gl type diagram

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


Solution

  • 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.