After compiling a shader with glCompileShader, I can call glGetShaderiv with GL_COMPILE_STATUS to check if the shader compiled successfully. I can also call glGetShaderInfoLog to get information about possible errors, warnings or other info. The information log returned by this function is unspecified.

In a tool where users can write their own shaders, I would like to print all errors and warnings from the compilation, but nothing if no warnings or errors were found. The problem is that the GL_COMPILE_STATUS returns only false if the compilation failed and true otherwise. If no problems were found, some drivers return empty info log from glGetShaderInfoLog, but some drivers can return something else such as "No errors.", which I do not want to print to the user. How is this problem generally solved?

  • \$\begingroup\$ Have you thought of checking the output of the compilation for the words "error" or "warning"? If there isn't any, than you don't print it, but if there is a warning, usually the output is " ([line_number]) : warning [warning_code] : [description]" \$\endgroup\$
    – Makers_F
    Commented Mar 3, 2013 at 16:05
  • \$\begingroup\$ Seems like all solutions are just variations of parsing the log and matching for known strings. I ended up checking for "shader was successfully compiled to run on hardware", which is the output from AMD drivers. Perhaps your idea would be more generic. \$\endgroup\$
    – msell
    Commented Mar 3, 2013 at 20:25

1 Answer 1


Well, the way I solve it is by always fetching the log (even if none is available) and after that check for success.

glGetShaderiv(m_HandleVertex, GL_INFO_LOG_LENGTH, &bufflen);
if (bufflen > 1)
    GLchar* log_string = new char[bufflen + 1];
    glGetShaderInfoLog(m_HandleVertex, bufflen, 0, log_string);
    LOG_TRACE("Log found for '%s.vert':\n%s", m_Name.GetData(), log_string);

    delete[] log_string;

glGetShaderiv(m_HandleVertex, GL_COMPILE_STATUS, &success);
if (success != GL_TRUE)
    LOG_ERROR("Failed to compile vertex shader.");
    return false; 

I did it this way because you might otherwise miss the warnings a shader returns. If a shader has warnings, but no errors, success will be true so you won't print the log, but warnings can also give you a clue as to why a shader fails to behave the way you want it.

  • 1
    \$\begingroup\$ The problem is that some drivers return non-empty info log even when there are neither errors nor warnings. Those I don't want to log. \$\endgroup\$
    – msell
    Commented Jun 11, 2012 at 9:59
  • 4
    \$\begingroup\$ It's driver-specific, which is a problem. I resolved it by checking if (strcmp(log_string, "No errors.")) but that's just for NVIDIA's drivers. Unless you want to add similar checks for all other drivers (NVIDIA, AMD, ATI, Intel, Windows, Mac, Linux) I'd say: learn to live with it. \$\endgroup\$
    – knight666
    Commented Jun 11, 2012 at 10:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .