0

编辑:好的,现在知道了: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;
}
4

1 回答 1

1

移动语句

mat4 MVP = projectionMatrix * modelMatrix ; //Should actually have the same value like testUni

进入main(). 着色器执行从 main 开始。如果要避免按顶点计算,请在外部预先计算矩阵并将其作为统一矩阵提供。

于 2013-01-03T19:46:17.323 回答