Reputation: 2142
I am completely stumped here. I have the following fragment shader working:
varying lowp vec4 fposition;
varying lowp vec4 fcolor;
varying lowp vec2 ftexturecoordinates;
void main() {
gl_FragColor = fcolor;
}
If I try to add anything at all (example: vec4 light position = vec4(-2.0, 2.0, 1.0, 1.0)
), it will not compile. I cannot figure out how to get error codes/descriptions, but I cannot get any of the normal OpenGL ES shaders to work. I have the same shader compilation code in this app as I have in all my other apps, so I know that section works fine. What, if anything, can I do to find information on the problem?
Upvotes: 1
Views: 1176
Reputation: 6008
After you compiled a shader, you can check the GL_COMPILE_STATUS
if it is GL_FALSE
, you can use use glGetShaderInfoLog
to get additional information on the compile error.
Here is a snippet that shows how to use glGetShaderInfoLog:
(I left the project specific error checking in for reference, but commented it out, as it wont work without the framework around it.)
glCompileShader(shader);
//mada_check_gl_error();
GLint compiled;
glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
//mada_check_gl_error();
if (!compiled)
{
GLint length;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
//mada_check_gl_error();
if (length > 0)
{
GLint infoLength;
char* infoBuf = (char*) malloc(sizeof(char) * length);
glGetShaderInfoLog(shader, length, &infoLength, infoBuf);
//mada_check_gl_error();
//mada_log(logERROR, infoBuf);
free(infoBuf);
//SysUtils::error("Error compiling shader. See log for info.");
}
//SysUtils::error("Failed to compile shader. No further info available.");
}
Upvotes: 3