// Check and warn about compile & link errors static bool check_glsl_errors(const char *filename, GLuint obj) { //check if shader or program bool isShader = (glIsShader(obj) == GL_TRUE); int infologLength = 0; char infoLog[1024]; if (isShader) glGetShaderInfoLog(obj, 1024, &infologLength, infoLog); else glGetProgramInfoLog(obj, 1024, &infologLength, infoLog); GLint status; if (isShader) glGetShaderiv(obj, GL_COMPILE_STATUS, &status); else glGetProgramiv(obj, GL_LINK_STATUS, &status); if (status == GL_FALSE) { Error("Error compiling shader: %s:\n%sOpenGL vendor: %s\nOpenGL renderer string: %s", filename, infoLog, glGetString(GL_VENDOR), glGetString(GL_RENDERER)); return false; } #if 0 if (!isShader) { // perform general validation that the program is usable glValidateProgram(obj); glGetProgramiv(obj, GL_VALIDATE_STATUS, &status); if (status == GL_FALSE) { Error("Error vaildating shader: %s:\n%sOpenGL vendor: %s\nOpenGL renderer string: %s", filename, infoLog, glGetString(GL_VENDOR), glGetString(GL_RENDERER)); return false; } } #endif // Log warnings even if successfully compiled // Sometimes the log is full of junk "success" messages so // this is not a good use for OS::Warning #ifndef NDEBUG if (infologLength > 0) { if (pi_strcasestr("infoLog", "warning")) Output("%s: %s", filename, infoLog); } #endif return true; }
// Check and warn about compile & link errors static bool check_glsl_errors(const char *filename, GLuint obj) { //check if shader or program bool isShader = (glIsShader(obj) == GL_TRUE); int infologLength = 0; char infoLog[1024]; if (isShader) glGetShaderInfoLog(obj, 1024, &infologLength, infoLog); else glGetProgramInfoLog(obj, 1024, &infologLength, infoLog); GLint status; if (isShader) glGetShaderiv(obj, GL_COMPILE_STATUS, &status); else glGetProgramiv(obj, GL_LINK_STATUS, &status); if (status == GL_FALSE) { #ifndef NDEBUG OS::Error("Error compiling shader: %s:\n%sOpenGL vendor: %s\nOpenGL renderer string: %s", filename, infoLog, glGetString(GL_VENDOR), glGetString(GL_RENDERER)); #else OS::Warning("Error compiling shader: %s:\n%sOpenGL vendor: %s\nOpenGL renderer string: %s\n\nS" "Pioneer will not work as intended. Try disabling shaders in the options or the config file.\n", filename, infoLog, glGetString(GL_VENDOR), glGetString(GL_RENDERER)); #endif shadersAvailable = false; shadersEnabled = false; return false; } // Log warnings even if successfully compiled // Sometimes the log is full of junk "success" messages so // this is not a good use for OS::Warning #ifndef NDEBUG if (infologLength > 0) { if (pi_strcasestr("infoLog", "warning")) fprintf(stderr, "%s: %s", filename, infoLog); } #endif return true; }