Hello Guest

GLSL: getUniformLocation

  • 0 Replies
  • 6521 Views
GLSL: getUniformLocation
« on: March 23, 2010, 14:04:31 »
Hey, I just can't get my shader location queries working  :-\

Update:
ARGHS! :D  Everything works fine, just didn't expect the GLSL compiler to ignore unused declarations... :-P



Shader files are loaded, compiled and linked without errors (syntax errors on purpose cause compilation errors, so I'm pretty sure).

My test vertex shader looks like this:
Code: [Select]
uniform float testUniform;

void main()
{
gl_Position = ftransform();
}

I'm trying to get the uniform location using this:
Code: [Select]
int location = GL20.glGetUniformLocation(program, BufferUtils.createByteString("testUniform", true));
Where createByteString:
Code: [Select]
public static ByteBuffer createByteString(String s, boolean nullTerminated) {
int length = s.length() + (nullTerminated ? 1 : 0);

ByteBuffer buff = BufferUtils.createByteBuffer(length);
buff.put(s.getBytes());

if (nullTerminated)
buff.put((byte) 0);

buff.flip();
return buff;
}

The program ID is valid (checked), the program is linked and in use, and the the uniform name is obviously correct.

Nevertheless the query always returns -1.

I have absolutely NO idea what's going on.

I thought maybe an encoding issue, but first loading the shader sources into a String and creating a ByteBuffer from the String the same way as in getUniformLocation works perfectly well aswell, the shaders are compiled and linked successfully.

I'm using Mac OS X Snow Leopard.

Thank you very much in advance!
« Last Edit: March 23, 2010, 14:20:46 by xindon »