I *think* my glUniformMatrix4fv calls are correct. My program has a class called 'ShaderProgram' which I use to spin up shaders, bind attributes, and get uniform locations. The object itself queries each uniform location ONCE and stores it in its own lookup table. It has a helper function that lets me update my matrix uniforms, referencing them by name.
I've stumbled upon some extra wierdness fiddling with this thing. In transitioning to the 2-matrix scheme I have set uProjection to the Identity matrix and uModelView to (Frustum x Translate x Rotate x Translate), and I set the vertex shader to set gl_Position = uProjection x uModelView x v_in. This works, but if I switch the values of uModelView and uProjection, only some faces show. This is extreemly odd since one matrix is just an Identity matrix and shouldn't really affect the output. (in other words, for Matrices M and I, I expect to see MxI=IxM, but that is not the case for some reason).
----------------------Shader Initialization Snippet:--------------------------
GL20.glAttachShader(program_id, vertex_shader_id);
GL20.glAttachShader(program_id, fragment_shader_id);
GL20.glLinkProgram(program_id);
// Delete Shader objects
GL20.glDeleteShader(vertex_shader_id);
GL20.glDeleteShader(fragment_shader_id);
// Get Uniform Locations
if (uniforms != null) {//Check if uniform locations are needed
Uniform_Location.clear();//Clear old uniform locations. needed if program is being recreated
for (int i = 0; i < uniforms.length; i++) {// For each uniform name get its location and store it in a lookup table.
Uniform_Location.put(uniforms, GL20.glGetUniformLocation(program_id, uniforms));
}
}
--------------glUniformMatrix4f usage-------------------------------
ByteBuffer matrix_buffer = ByteBuffer.allocateDirect(64).order(ByteOrder.nativeOrder()); //JAVA DIRECT NIO BUFFER, for use with LWJGL
public void UniformMatrix(String name, float[] m) {
Integer location = Uniform_Location.get(name);//Lookup uniform location from table
if (location != null) {
matrix_buffer.clear();//Restart write at beginning of buffer
matrix_buffer.asFloatBuffer().put(m).flip(); //Write to buffer and set its capacity
GL20.glUniformMatrix4f(location, 1, false, matrix_buffer);//Send the matrix data to opengl
}
return;
}