Jump to content
  • Advertisement
Sign in to follow this  
TTT_Dutch

glUseProgram = GL_INVALID_OPERATION

This topic is 2568 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, I am trying to create a shader class that is easy to use and easy to send values to. Now I am trying to test some of it and I get the error GL_INVALID_OPERATION right after I call glUseProgram. I can't figure out what is wrong but if someone could help, that would be great. Here is my code:


main.cpp: http://pastebin.com/w1JMzdqm
shader.cpp: http://pastebin.com/zuXe7Fut

Thanks ahead,
Brent

Share this post


Link to post
Share on other sites
Advertisement
Are you sure that glUseProgram is actually the function causing the error? Errors flags are not reset until you check them, so it can be any function before glUseProgram, until the point where you last called glGetError to ensure that there are no errors flags left. Furthermore, you should check the documentation to see about what conditions causes that error flag to be set for the particular function. The specification states that glUseProgram can only cause an invalid operation under one condition, and you're not checking that condition.

Share this post


Link to post
Share on other sites
While you're developing, it's useful to scatter glError calls around in your code all over the place for this reason -- although remember that calling glError while in some states is an error itself.

Personally I use a macro for this which takes a string context parameter, to make it simpler to find the command which triggers the error. It's a macro rather than a function so that later on I can simply define it to be null and strip out the glError calls. (Because glError acts like a glFlush reducing pipelining).

Share this post


Link to post
Share on other sites
you aren't checking if the shaders compiled or link properly
http://opengl.org/wiki/Tutorial1:_Rendering_shapes_with_glDrawRangeElements,_VAO,_VBO,_shaders_%28C%2B%2B_/_freeGLUT%29

Share this post


Link to post
Share on other sites
Ok I used to have Shaders loading right but now they are not compiling with these errors:
Vertex shader failed to compile with the following errors:
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: 0:1: error(#106) Version number not supported by GL2
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: error(#273) 3 compilation errors. No code generated

Fragment shader failed to compile with the following errors:
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: 0:1: error(#106) Version number not supported by GL2
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: error(#273) 3 compilation errors. No code generated


And both my shaders kinda look like this:
#version 330
....
main(void)
{
...
}

Share this post


Link to post
Share on other sites

While you're developing, it's useful to scatter glError calls around in your code all over the place for this reason -- although remember that calling glError while in some states is an error itself.

Personally I use a macro for this which takes a string context parameter, to make it simpler to find the command which triggers the error. It's a macro rather than a function so that later on I can simply define it to be null and strip out the glError calls. (Because glError acts like a glFlush reducing pipelining).


Ok I did that and I still get the error when I try to use the program. Even thought all of the sudden my shaders aren't compiling.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!