Hi,
I can't figure out what is going wrong. Actually I don't know if I'm using glGetUniformLocation in the right way. Here's a piece of code:
shaderIds[0] = glCreateProgram();
testError("ERROR: Could not create the shader program");
shaderIds[1] = ShaderUtil.loadShader("SimpleShader.fragment.glsl", GL_FRAGMENT_SHADER);
shaderIds[2] = ShaderUtil.loadShader("SimpleShader.vertex.glsl", GL_VERTEX_SHADER);
glAttachShader(shaderIds[0], shaderIds[1]);
glAttachShader(shaderIds[0], shaderIds[2]);
glLinkProgram(shaderIds[0]);
testError("ERROR: Could not link the shader program");
modelMatrixUniformLocation = glGetUniformLocation(shaderIds[0], "modelMatrix");
viewMatrixUniformLocation = glGetUniformLocation(shaderIds[0], "viewMatrix");
projectionMatrixUniformLocation = glGetUniformLocation(shaderIds[0], "projectionMatrix");
testError("ERROR: Could not get the shader uniform locations");
The problem is the last test. It fails with the following message: "Invalid Operation".
I've found some reasons for this problem in the internet, but none of them was the case.
What could be happening?
PS: loadShader is a method I created to load shaders. All it does is load the shader from a file to a string and then create the shader with the corresponding source loaded and compile it. The return value is the shaderId returned by glCreateShader function.