ES 2.0: glUniform generates GL_INVALID_OPERATION

Started by
1 comment, last by FelixKlakow 12 years, 5 months ago
Hi,

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++);
// GL_INVALID_OPERATION here
}



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] )


Cheers
Felix
Advertisement
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?
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); } }
Are your shader binded before setting it's uniform parameters?




Is your shader binded before setting it's uniform parameters?

This topic is closed to new replies.

Advertisement