编辑: 好吧,现在明白了:D 问题:完全忘了glm使用colum-major矩阵。只需要将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;
}
答案 0 :(得分:1)
移动声明
mat4 MVP = projectionMatrix * modelMatrix ; //Should actually have the same value like testUni
进入main()
。着色器执行从main开始。如果要避免逐顶点计算,请在外部预先计算矩阵并将其作为统一值提供。