Skip to content

Instantly share code, notes, and snippets.

@davawen
Created March 2, 2022 15:53
Show Gist options
  • Save davawen/af1490ffb3bbcf9ddc0cbab82e9f27aa to your computer and use it in GitHub Desktop.
Save davawen/af1490ffb3bbcf9ddc0cbab82e9f27aa to your computer and use it in GitHub Desktop.
/// Takes a symbolic type constant and returns its size
/// Probably missing a few types but those were the most important
size_t get_sizeof_type(GLenum type)
{
switch(type)
{
case GL_BYTE:
case GL_UNSIGNED_BYTE:
return sizeof(GLbyte);
case GL_SHORT:
case GL_UNSIGNED_SHORT:
return sizeof(GLshort);
case GL_INT_2_10_10_10_REV:
case GL_INT:
case GL_UNSIGNED_INT_2_10_10_10_REV:
case GL_UNSIGNED_INT:
return sizeof(GLint);
case GL_FLOAT:
return sizeof(GLfloat);
case GL_DOUBLE:
return sizeof(GLdouble);
case GL_FIXED:
return sizeof(GLfixed);
case GL_HALF_FLOAT:
return sizeof(GLhalf);
}
return 0;
}
@sylv256
Copy link

sylv256 commented Feb 16, 2024

Very helpful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment