glGetUniformLocation在nvidia卡上返回

glGetUniformLocation在nvidia卡上返回

本文介绍了glGetUniformLocation在nvidia卡上返回-1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行glGetUnfiormLocation调用时遇到问题。当在学校计算机上运行ATI显卡构建项目时,程序功能完美无缺。但是,使用运行nvidia卡的学校计算机,对glGetUniformLocation的调用返回-1。

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");

这里是顶点着色器

    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对统一的优化,因为它们都在使用,属性。任何洞察的事情将非常感谢。

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.

推荐答案

链接OpenGL程序在发生失败时不会您必须。

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

这篇关于glGetUniformLocation在nvidia卡上返回-1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 23:59