OpenGL: get the size of a type with its symbolic macro

Viewed 128

Symbolic constants are often used to pass type information in OpenGL, eg:

// Can be GL_BYTE, GL_UNSIGNED_BYTE, GL_INT, etc...
glVertexAttribPointer(/*...*/, GL_FLOAT, /*...*/);

I searched to see if there was a function in openGL to get the size of that sort of constant, but couldn't find much about it, so I'm asking here. (beyond just brute forcing it).

// Works but not very elegant and error prone
size_t foo(GLenum type) {
    switch(type) {
        case GL_INT:
            return sizeof(GLint);
        /* ... */
    }
}
0 Answers
Related