Error In Shaders / glUseProgram


I’m tryin’ to add a texture to a cube. So I modified the shaders. I’m using this tutorial as groundwork: Tutorial But my debug,htm file says, that glUseProgram generates 1282 error code, which is a GL error: “Unknown error”.
This happens after loading both vertex and fragment shader. (You can just view debug.htm in any browser)

You can find the project on github GitHub
the init_engine() method in en_app.cpp is the one i would want you to check for me (please). 'cause due to the fact i don’t get any more specific error_code, I’m currently helpless.


BTW: You might wanna use “?ts=2” at the end of a domain, while watching a file. For some reasons github cannot get my origin tab size.

1282 = 0x0502 = GL_INVALID_OPERATION.

glUseProgram() will generate that error if the program isn’t valid (i.e. failed to or link).

You should query the compilation and linking status with glGetShaderiv(GL_COMPILE_STATUS) and glGetProgramiv(GL_LINK_STATUS) respectively. If either of those return a status of zero, you should retrieve the corresponding log with glGetShaderInfoLog() or glGetProgramInfoLog().

Thanks. I implemented that and it helped a bit. I was able to spot some errors in the shader files. but their is some weird behavior. glsl function “texture” is not available in glsl 1.10. but… debug.htm shows me that glsl version is 1.30 using glGetString(GL_SHADING_LANGUAGE_VERSION)?

so i searched the web and spottet texture2D function for fragment shader, which works. but it’s depracated. and now I recieve the error “fragment shader varying in_uv not written by vertex shader . --end” I am confused. why are the shaders not working? and why is texture function not available?

I updated everything on github.

Your shaders should declare the GLSL version they are written in by specifying #version XYZ on the first non-whitespace line.
The varyings in the vertex and fragment shader do not have the same name, but since those are the variables that are used to communicate from one shader stage to the other the names must match - you use varying <type> out_* in the vertex shader and varying <type> in_* in the fragment shader.

Thanks, it works now. Didn’t know the names have to be the same.