PDA

View Full Version : Error In Shaders / glUseProgram



PadMad
02-02-2016, 08:04 AM
Hey,

I'm tryin' to add a texture to a cube. So I modified the shaders. I'm using this tutorial as groundwork: Tutorial (http://www.opengl-tutorial.org/beginners-tutorials/tutorial-5-a-textured-cube/) 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 (https://github.com/Rawocar/engine_test)
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.

Thanks

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.

GClements
02-02-2016, 11:08 AM
But my debug,htm file says, that glUseProgram generates 1282 error code, which is a GL error: "Unknown error"

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().

PadMad
02-02-2016, 03:21 PM
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.

carsten neumann
02-02-2016, 07:42 PM
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.

PadMad
02-03-2016, 04:26 AM
Thanks, it works now. Didn't know the names have to be the same.