GLSL 330矩阵计算错误{无编译错误}

GLSL 330 Matrix-Computation Error {No compile error}

本文关键字:错误 编译 计算 GLSL      更新时间:2023-10-16

编辑:好了,现在明白了: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

转换为CCD_ 1。着色器执行从main开始。如果要避免逐顶点计算,请在外部预计算矩阵,并将其作为统一矩阵提供。