glGetError()
- ‘error log’
glGetShaderInfoLog ()
- ‘shader info log’
When there is a bug in the shader, the error message appears in the shader info log instead of the error log. why is this?
In my shader, I made a deliberate syntactical error by missing out the semicolon at the end of a line; gl_Position = u_MVP * position
After compiling the shader, glGetError()
returns 0, but then when the compile status is checked via glGetShaderiv()
, GL_FALSE is returned with this message:
“ERROR: 0:11: ‘}’ : syntax error syntax error”
Is there a particular reason why this error appears in the shader info log as opposed to the error log?
while(glGetError != 0); // clear any pre-existing errors
glCompileShader(VertexShader);
unsigned int error = glGetError();
if(error != 0)
std::cout << "OpenGL Error: " << error << std::endl;
else
{
int succeeded;
glGetShaderiv(VertexShader, GL_COMPILE_STATUS, &succeeded)
if(!succeeded)
{
std::cout << "Failed to compile vertex shader\n";
int buf_size;
GLCall(glGetShaderiv(VertexShader, GL_INFO_LOG_LENGTH, &buf_size));
std::vector<char> vec(buf_size);
GLCall(glGetShaderInfoLog(VertexShader, buf_size, nullptr, &vec[0]));
for (auto v : vec)
std::cout << v;
}
}