2

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.

4

1 回答 1

2

链接 OpenGL 程序失败时不会给出 OpenGL 错误。您必须实际检查程序是否正确链接

于 2012-11-21T04:44:04.657 回答