PDA

View Full Version : Info log of a failed shader compile: 0��t What is wrong?



Narann
03-10-2015, 10:10 PM
Hello GL guru!

This problem is such weird I'm sure it has a simple explanation.

This code:

https://github.com/Narann/mupen64plus-video-rice/blob/master/src/OGLCombiner.cpp#L134



GLint status;
pglGetShaderiv(shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
printf("Compile shader failed:\n");
printf("Shader type: ");
switch(shaderType)
{
case GL_VERTEX_SHADER :
printf("Vertex\n");
break;
case GL_FRAGMENT_SHADER :
printf("Fragment\n");
break;
default:
printf("Unknown?\n");
break;
}
GLint param = 0;
pglGetShaderiv(shader, GL_INFO_LOG_LENGTH, &param);

GLsizei infoLogLength = (GLsizei) param;
assert( infoLogLength >= 0 );

GLchar infoLog[ infoLogLength ];
pglGetShaderInfoLog(shader, infoLogLength, NULL, infoLog);

printf("Info log:\n%s\n", infoLog);
printf("GLSL code:\n%s\n", shaderSrc);

pglDeleteShader(shader); OPENGL_CHECK_ERRORS
}


Return this:

http://pastebin.com/grRRFbFh



Compile shader failed:
Shader type: Fragment
Info log:
0��t


Can anyone explain me why I get this weird output message? What is wrong in my code? Is this driver related?

Notice I don't have any problem with Desktop GL but it's GL ES 2 which seems to be unable to compile.

A big thanks in advance! :)

Note: The "OPENGL_CHECK_ERRORS" is empty.

Alfonse Reinheart
03-10-2015, 10:29 PM
This line seems rather dubious, in light of the fact that it's not legal C++ (of any version).


GLchar infoLog[ infoLogLength ];

This is allowed under C99 or C11 rules, but from the rest of your code, you're clearly compiling C++. That should have failed to compile.

The correct way to do this would be to use actual C++. For example (https://www.opengl.org/wiki/Example/GLSL_Shader_Compile_Error_Testing), a std::string or a std::vector as a buffer, rather than a stack object.



std::vector<GLchar> errorLog(maxLength);
glGetShaderInfoLog(shader, maxLength, NULL, &errorLog[0]);

GClements
03-11-2015, 01:03 AM
Note: The "OPENGL_CHECK_ERRORS" is empty.
You might try actually checking for errors via glGetError().

E.g. if glCreateShader() fails, the functions which query its state will also fail, meaning that status, param, etc will be unchanged.

You might also want to initialise such variables so that the behaviour is sane even if the functions which are meant to set them fail.

Narann
03-11-2015, 08:21 AM
Thanks Alfonse. I'm used to C but the code is a weird mix of C and C++. Thanks for pointing this. I will try using vector. :)

What is weird is that this code work on desktop GL but not on GLES...

GClements: This is actually a macro (https://github.com/Narann/mupen64plus-video-rice/blob/master/src/OGLDebug.h#L22). I was just saying this just in case anyone ask what the macro would do. I will try to activate it. :)