Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Uniform in GLSL

  1. #1
    Junior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    Montreal, Canada
    Posts
    106

    Uniform in GLSL

    I have a problem in GLSL. My uniform never seem to make it through to vertex or fragment shader.

    Here is my fragment Shader:
    uniform int nTexEnvMode0;
    uniform sampler2D nTextIdx[8];
    void main(void)
    {
    vec4 texval;
    gl_FragColor = gl_Color;
    if (nTexEnvMode0 == 1)
    {
    texval = texture2D(nTextIdx[nTex], vec2(gl_TexCoord[nTex]));
    gl_FragColor *= texval;
    }
    };

    As you can see, this is a very basic shader trying to apply a texture if my uniform is set.

    I set it the following way:

    int nTexEnvMode0Location = glGetUniformLocationARB( nProgramObject, "nTexEnvMode0");
    glUniform1iARB( nTexEnvMode0Location, 1 );

    To me this should set the label nTexEnvMode0 to a permanent value of 1 since I don't change it afterward. But it doesn't work. It remains untexture, but the behaviour is fine if I force nTexEnvMode0 to 1 inside my shader, which prooves the problem is with the uniform.

    Am I doing anything wrong?

    BTW I'm using a GeForce 5900 Ultra with the latest driver.

    Thanks

  2. #2
    Junior Member Regular Contributor
    Join Date
    Oct 2000
    Location
    Montreal, Canada
    Posts
    106

    Re: Uniform in GLSL

    Hum, no answer... I didn't think it was a though one...

    The easy version of the question would be: Am I the only not being able to control uniforms?

    Vincent

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    570

    Re: Uniform in GLSL

    where is this 'nTex' coming from that you are using as an index to gl_TexCoord[] and into your nTextureIdx[] array?

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2003
    Posts
    29

    Re: Uniform in GLSL

    Could you post a test app? Or would that be impractical?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •