Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: [Solved] GL_INVALID_OPERATION error when using Shader setParameter function  (Read 5339 times)

0 Members and 2 Guests are viewing this topic.

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
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.
« Last Edit: February 27, 2016, 08:00:26 pm by Rob92 »

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: GL_INVALID_OPERATION error when using Shader setParameter function
« Reply #1 on: February 25, 2016, 10:26:46 pm »
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?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: GL_INVALID_OPERATION error when using Shader setParameter function
« Reply #2 on: February 25, 2016, 11:35:27 pm »
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.
You should consider building SFML yourself from the source if this is an immediate requirement (or even if it is not).

Technically, setParameter is deprecated and setUniform should be used instead.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: GL_INVALID_OPERATION error when using Shader setParameter function
« Reply #3 on: February 27, 2016, 04:22:07 pm »
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.

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: GL_INVALID_OPERATION error when using Shader setParameter function
« Reply #4 on: February 27, 2016, 04:34:47 pm »
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.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Rob92

  • Newbie
  • *
  • Posts: 35
    • View Profile
    • Email
Re: GL_INVALID_OPERATION error when using Shader setParameter function
« Reply #5 on: February 27, 2016, 04:49:24 pm »
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)