Sign in to follow this  
TTT_Dutch

glUseProgram = GL_INVALID_OPERATION

Recommended Posts

TTT_Dutch    240
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: [url="http://pastebin.com/w1JMzdqm"]http://pastebin.com/w1JMzdqm[/url]
shader.cpp: [url="http://pastebin.com/zuXe7Fut"]http://pastebin.com/zuXe7Fut[/url]

Thanks ahead,
Brent

Share this post


Link to post
Share on other sites
Brother Bob    10344
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
Katie    2244
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
V-man    813
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
TTT_Dutch    240
Ok I used to have Shaders loading right but now they are not compiling with these errors:
[code]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
[/code]

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

Share this post


Link to post
Share on other sites
TTT_Dutch    240
[quote name='Katie' timestamp='1307879460' post='4822363']
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).
[/quote]

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this