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 6 of 6

Thread: Getting Uniform Locations

  1. #1
    Intern Newbie
    Join Date
    Feb 2003
    Posts
    41

    Getting Uniform Locations

    Hi... ive created some extremely simple GLSL shader. It links and compiles without any glError/Linker Error/Compile error for me. The problem is that glGetUniformLocationARB always returns -1, even tough the variables definately exist in the shader i passed to GL. Any ideas?

  2. #2
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Getting Uniform Locations

    Since there isn't much room for errors within glGetUniformLocationARB, only two things can happen : You didn't wrote the parameter's name casesensitive (e.g. texture0 instead of Texture0) or you have specified the wrong programobject.

  3. #3
    Intern Newbie
    Join Date
    Feb 2003
    Posts
    41

    Re: Getting Uniform Locations

    Well i wrote the variable names correctly. As my program handle im getting a strange value ( hProgram==0x80000001 ) But commands like linking etc are obviously working because if i create some errors in the source, they are reported correctly. Also theres no glError being created when i call glCreateProgramObjectARB

    [This message has been edited by Dtag (edited 12-31-2003).]

  4. #4
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Getting Uniform Locations

    Are you sure that the programobject to which those parameters belong is the current? I've noticed that it won't work if you pass parameters for PO1 if e.g. PO2 is bound, so make sure you make something like this :
    Code :
    glUseProgramObjectARB(ProgramObject);
    glGetUniformLocationARB(ProgramObject, ...);

  5. #5
    Intern Newbie
    Join Date
    Feb 2003
    Posts
    41

    Re: Getting Uniform Locations

    Yep im quite sure about that.
    You can see my code here
    http://www.pay4hits.de/glsl.txt
    The uniform location is requested at the very end if linked is true...
    Just for clarification: my shader files look like this:

    [VP]
    //VertexProgramHere
    [FP]
    //FragmentProgramHere
    EOF

    [This message has been edited by Dtag (edited 12-31-2003).]

  6. #6
    Intern Newbie
    Join Date
    Feb 2003
    Posts
    41

    Re: Getting Uniform Locations

    Hmmm i just fixed the bug... It was because i didnt actually USE the uniform variables in the shader i just declared them ... the compiler obviously optimized them away

Posting Permissions

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