Zev
Zev

Reputation: 21

glGetUniformLocation return -1 on nvidia cards

I've been having an issue running glGetUnfiormLocation calls. While building a project on school computers running ATI graphics cards, the program functions flawlessly. However, using the school computers running nvidia cards, the calls to glGetUniformLocation return -1.

//c++ side
glLinkProgram(ShaderIds[0]);
ExitOnGLError("ERROR: Could not link the shader program");

ModelMatrixUniformLocaion = glGetUniformLocation(ShaderIds[0], "ModelMatrix");
ViewMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ViewMatrix");
ProjectionMatrixUniformLocation = glGetUniformLocation(ShaderIds[0], "ProjectionMatrix");

ExitOnGLError("ERROR: Could not get the shader uniform locations");

And here is the vertex shader

    layout(location=0) in vec4 in_Position;
    layout(location=1) in vec4 in_Color;
    layout(location=2) in vec2 in_Coord;

    uniform mat4 ModelMatrix;
    uniform mat4 ViewMatrix;
    uniform mat4 ProjectionMatrix;

    varying vec2 v_UVCoord;
    out vec4 ex_Color;

    void main(void)
    {
        gl_Position = (ProjectionMatrix * ViewMatrix * ModelMatrix) * in_Position;
        gl_PointSize = in_Coord.x; 
        ex_Color = in_Color;
        v_UVCoord = in_Coord; 
    }

From what I can tell, it shouldn't be giving me -1 based on optimization of the uniforms, because they are all in use, as are the attributes. Any insight into the matter would be greatly appreciated.

Upvotes: 2

Views: 484

Answers (1)

Nicol Bolas
Nicol Bolas

Reputation: 474256

Linking an OpenGL program does not give an OpenGL error when it fails. You must actually check to see if the program linked properly.

Upvotes: 2

Related Questions