Results 1 to 2 of 2

Thread: GetUniformLocation returning -1

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    2

    GetUniformLocation returning -1

    I have the following uniform block:

    Code :
    uniform BlobSettings {
      vec4 InnerColor;
      vec4 OuterColor;
      float RadiusInner;
      float RadiusOuter;
    };

    I can query how many of these I have and their name and get the correct answer:

    Code :
    for(int i=0; i < activeUniformsCount; i ++ {
      GetActiveUniform(shaderProgramID, i, maxLength, out written, out size, out type, name );
      int location = Program.GetUniformLocation(shaderProgramID, name);
    }

    I get the value in name of:
    BlobSettings.InnerColor
    BlobSettings.OuterColor
    BlobSettings.RadiusInner
    BlobSettings.RadiusOuter

    I even get the right type out.

    However, the value of location is always -1.

    I am also asking because I get similar results for GetUniformIndices (all indicies are -1).

    I have to be doing something wrong! What is it?

    Note that the code is out of the book Getting Started With GLSL 4.0 (pg 38-40).

  2. #2
    Junior Member
    Join Date
    Nov 2011
    Posts
    2

    Re: GetUniformLocation returning -1

    Reply to myself:

    Although the GetUniformLocation is still returning -1, I had mentioned that GetUniformIndices was also returning -1 as follows:

    I am also asking because I get similar results for GetUniformIndices (all indicies are -1).
    The example in the book is as follows:

    Code :
    const GLchar *names[] = { "InnerColor", "OuterColor", "RadiusInner", "RadiusOuter" };
    GLuint indices[4];
    glGetUniformIndices(programHandle, 4, names, indices);

    when I change names to this:

    Code :
    const GLchar *names[] = { "BlobSettings.InnerColor", "BlobSettings.OuterColor", "BlobSettings.RadiusInner", "BlobSettings.RadiusOuter" };

    It works.

Similar Threads

  1. Replies: 6
    Last Post: 08-11-2011, 07:21 PM

Posting Permissions

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