glGetUniformLocation在nvidia卡上返回-1

时间:2012-11-21 04:09:40

标签: c++ opengl glsl

我在运行glGetUnfiormLocation调用时遇到了问题。在运行ATI显卡的学校计算机上构建项目时,该程序功能完美无缺。但是,使用运行nvidia卡的学校计算机,对glGetUniformLocation的调用返回-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");

这是顶点着色器

    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; 
    }

据我所知,它不应该根据制服的优化给我-1,因为它们都在使用,属性也是如此。任何有关此事的见解将不胜感激。

1 个答案:

答案 0 :(得分:2)

链接OpenGL程序 not 在失败时发出OpenGL错误。您必须actually check to see if the program linked properly