SFML community forums
Help => Graphics => Topic started by: Rob92 on February 25, 2016, 10:05:48 pm
-
I'm getting this error when I try to set a uniform in my fragment shader:
An internal OpenGL call failed in Shader.cpp(286).
Expression:
GLEXT_glUniform(location, x)
Error description:
GL_INVALID_OPERATION
The specified operation is not allowed in the current state.
I'm simply trying to set a uniform int in my fragment shader.
Good thing to note: This error does NOT occur when I build in Release mode, just in Debug mode.
-
Ok apparantly I fixed it if I make the uniform a float and not an int.
My question is then, why can't it be an integer?
-
sf::Shader::setParameter() doesn't support ints.
The latest master of SFML has a newer version of sf::Shader that has setUniform() instead and that also supports ints (https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/Shader.hpp#L342).
You should consider building SFML yourself from the source (https://github.com/SFML/SFML) if this is an immediate requirement (or even if it is not).
Technically, setParameter is deprecated and setUniform should be used instead.
-
Despite the fact that I now use setUnfirom(string, int) it still gives me the exact same error.
If I cast my int to a float it works again just like when I used setParameter.
-
OpenGL doesn't do any type conversions for you, and SFML no longer does either. If you use a float type in your GLSL, you will be expected to pass it a float in your code as well. If you don't have any floats lying around, you will have to static_cast<> your data to floats yourself.
-
Ah I forgot I changed my uniform int to a float to make it work with setParameter, so I forgot to change it back to an int. Thanks for pointing that out :) (it works now)