我有这个着色器代码(GLSL):
#version 420
in vec4 vertex;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main()
{
gl_Position = modelViewMatrix * projectionMatrix * vertex;
}
Run Code Online (Sandbox Code Playgroud)
glUniformMatrix4fv(location, 1, false, sendArray);location
我已经验证"location"和"sendArray"包含正确的数据.这里发生了什么?
编辑:问题似乎是在glUniformMatrix4fv调用中,但我不知道它有什么问题.
设置的代码
GLint location;
GLint location = glGetUniformLocation(this->programID, uniform.c_str());
if (location == -1)
{
throw ShaderVariableNotFoundException(uniform, this->programID);
}
Run Code Online (Sandbox Code Playgroud)
如下:
#version 420
in vec4 vertex;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
void main()
{
gl_Position = modelViewMatrix * projectionMatrix * vertex;
}
Run Code Online (Sandbox Code Playgroud)
glUniformMatrix4fv(location, 1, false, sendArray);我修好了,但是我不愿意告诉你所有的解决方案,因为它有多尴尬......
一世...
我忘了绑定着色器程序.
我很遗憾浪费你所有的时间.