Created
September 29, 2014 17:01
-
-
Save ryanseys/4ede7c5390585792b5cd to your computer and use it in GitHub Desktop.
Check shaders for errors
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
void checkShaderForErrors(GLuint shaderID) { | |
// check shader for errors | |
glGetShaderiv(shaderID, GL_COMPILE_STATUS, &compile_status); | |
glGetShaderiv(shaderID, GL_INFO_LOG_LENGTH, &logLength); | |
logMsg = new GLchar[logLength + 1]; | |
glGetShaderInfoLog(shaderID, logLength, NULL, logMsg); | |
if (compile_status != GL_TRUE) { | |
fprintf(stderr, "Error in shader(%i): %s\n", shaderID, logMsg); | |
std::exit(EXIT_FAILURE); | |
} | |
} | |
void checkLinkForErrors(GLuint programID) { | |
glGetProgramiv(programID, GL_LINK_STATUS, &link_status); | |
glGetProgramiv(programID, GL_INFO_LOG_LENGTH, &logLength); | |
logMsg = new GLchar[logLength + 1]; | |
glGetProgramInfoLog(programID, logLength, NULL, logMsg); | |
if (link_status != GL_TRUE) { | |
fprintf(stderr, "Error in linking program: %s\n", logMsg); | |
std::exit(EXIT_FAILURE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment