You can get compilation errors by extracting the "information log":
GLuint nVertexShader, nPixelShader; // handles to objects GLint vertCompiled, fragCompiled; // status values GLint linked; glCompileShader(nVertexShader); glGetShaderiv(nVertexShader, GL_COMPILE_STATUS, &vertCompiled);
if vertCompiled (or fragCompile) == 0, do this to understand why:
int infologLength = 0; int charsWritten = 0; glGetShaderiv(nVertexShader, GL_INFO_LOG_LENGTH, &infologLength); if (infologLength > 0) { GLchar* infoLog = (GLchar *)malloc(infologLength); if (infoLog == NULL) { printf( "ERROR: Could not allocate InfoLog buffer"); exit(1); } glGetShaderInfoLog(nVertexShader, infologLength, &charsWritten, infoLog); printf( "Shader InfoLog:\n%s", infoLog ); free(infoLog); }
You can do the same with the link, just set == 0 for the link and get the log as above:
glLinkProgram(m_nProgram); glGetProgramiv(m_nProgram, GL_LINK_STATUS, &linked);
source share