Last active
June 26, 2017 16:11
-
-
Save drdrsh/b8d46e281135aa470cfcb3c089ef48ac to your computer and use it in GitHub Desktop.
A templated function to convert C++ types to OpenGL types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> GLenum typeToGL() { | |
if (typeid(T) == typeid(float)) { | |
return GL_FLOAT; | |
}; | |
if (typeid(T) == typeid(double)) { | |
return GL_DOUBLE; | |
}; | |
if (typeid(T) == typeid(char)) { | |
return GL_BYTE; | |
}; | |
if (typeid(T) == typeid(unsigned char)) { | |
return GL_UNSIGNED_BYTE; | |
}; | |
if (typeid(T) == typeid(int)) { | |
return GL_INT; | |
}; | |
if (typeid(T) == typeid(unsigned int)) { | |
return GL_UNSIGNED_INT; | |
}; | |
if (typeid(T) == typeid(short)) { | |
return GL_SHORT; | |
}; | |
if (typeid(T) == typeid(unsigned short)) { | |
return GL_UNSIGNED_SHORT; | |
}; | |
return GL_INVALID_ENUM; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment