Here's my set uniform code:
public static boolean setUniform(GL3 gl, String name, Object value) {
if (shaderProgram == -1) {
throw new IllegalStateException("Shaders not initialized yet");
}
gl.glUseProgram(shaderProgram);
int location;
if (!uniforms.containsKey(name)) {
location = gl.glGetUniformLocation(shaderProgram, name);
if (location == -1) {
return false;
}
uniforms.put(name, location);
} else {
location = uniforms.get(name);
}
double[][] matrix = (double[][]) matrix;
if (matrix.length != 4 || matrix[0].length != 4) {
throw new UnsupportedOperationException("Unsupported matrix size " + matrix[0].length + "x" + matrix.length);
}
float[] fMat = new float[16];
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
fMat[j * 4 + i] = matrix[i][j];
}
}
gl.glUniform4fv(location, 1, fMat, 0);
return true;
}
And here's the error:
com.jogamp.opengl.GLException: Thread[#39,AWT-EventQueue-0,6,main] glGetError() returned the following error codes after a call to glUniform4fv(<int> 0x0, <int> 0x1, <[F>, <int> 0x0): GL_INVALID_OPERATION ( 1282 0x502)
Why is there this issue? Shader init code in comment.