编辑:
好吧,现在:D
问题:完全忘记了glm使用列主矩阵。只需将GL_TRUE更改为GL_FALSE就可以了。
我尝试用我的ProjectionMatrix计算我的ModelMatrix。像这样:
#version 330
layout(location = 0) in vec4 position;
layout(location = 1) in vec4 color;
uniform mat4 projectionMatrix; //This are the Matrixes from my cpp-app
uniform mat4 modelMatrix; //With a debugger that can show all active uniforms i checked their values: They're right!
uniform mat4 testUni; //Here I checked if its working when I precompute the model and perspective matrices in my source: works
mat4 viewMatrix = mat4(1.0f);
noperspective out vec4 vertColor;
mat4 MVP = projectionMatrix * modelMatrix ; //Should actually have the same value like testUni
void main()
{
gl_Position = testUni * position ; //Well... :) Works
gl_Position = MVP * position ; //Well... :) Doesn't work [Just the perspective Transforn]
vertColor = position;
}
最佳答案
移动陈述
mat4 MVP = projectionMatrix * modelMatrix ; //Should actually have the same value like testUni
进入
main()
。着色器执行从main开始。如果要避免按顶点计算,请在外部预先计算矩阵并将其统一提供。关于c++ - GLSL 330矩阵计算错误{无编译错误},我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14144344/