Advertisement Jump to content
Sign in to follow this  

OpenGL ES 2.0: glUniform generates GL_INVALID_OPERATION

This topic is 2633 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


i'm currently trying to create a OpenGL ES 2.0 application for the IPad with MonoTouch.

I already managed to:
- Load Models
- Use & Compile Shaders
- Display a 3D Model

At this point i want to use a skybox for my background and show some UI-Buttons.
To make thinks short here are problems:

[subheading]1. Cube Map is shown colorized red[/subheading]
I noticed that i get a GL_INVALID_OPERATION error when calling glUniform{i} ( Mono Touch hides the specific implementations ) and i think the sampler-id is never given to the shader correctly.

// [...] Active Program etc [...]

Int32 count = 0;
foreach (TextureParameter texture in parameters.TextureParameters)
(texture.Texture as Texture).Use(count);
// No error above this line
GL.Uniform1(_Uniforms[texture.Name].Location, count++);

The "Use(count)" method does the following:
if (_Handle != 0)
if (slot > 31 || slot < 0) throw new ArgumentOutOfRangeException("slot");
GL.ActiveTexture((All)((Int32)All.Texture0 + slot));
GL.BindTexture(TextureType, _Handle);
// Texture type is in this case All.TextureCubeMap

Of course the shader has the uniform and the location of it is 3 ( There is also a MVP-Matrix ).
The shader compiler shows no errors so the shader should work.

[subheading]2. Set Model-View-Projection Matrix via glUniformMatrix [/subheading]
I'm trying to set the MVP matrix via the glUniformMatrix, but this generates also a GL_INVALID_OPERATION error. ( Note: It's not the same shader! )
This also worked in other shaders.

At this point i'm very annoyed, because it consumes a lot of time, and the project is urgent anyway.
I've tryed a lot of things to make it work, but it won't.
I've also posted the question on stackoverflow and you can grab some bounty for the questions. ( [1] [2] )


Share this post

Link to post
Share on other sites
I had something like that (that your uniforms werent set) in an application too, without any reason.
I changed computer and it works. You may try to change your uniform_names.

Are your uniforms correctly localized with glGetUniformLocation and are your values valid to the
uniform type?

Share this post

Link to post
Share on other sites
It turned out that the Uniform location changed. Don't ask me why, besause the shader is completly initialized.
So i changed the Uniform.Location property from a static getter to something like this:
public Int32 Location { get { return GL.GetUniformLocation(_Program, Name); } }

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!