首页 > 解决方案 > 当我将我的着色器与我的 glm 透视相乘时,一切都消失了

问题描述

我一直在尝试不同的参数,只是想看看这是否是问题所在,但我仍然一无所获。我对这个矩阵不太了解,但我尝试乘以的每一种方式都会得到相同的结果,即黑屏。我在下面包含的代码只是一个片段,我认为只有看到它才能了解问题所在。请记住,如果不将我的投影矩阵乘以我的顶点着色器,一切都可以正常工作。

这是我的透视和正交投影

glm::mat4 theprojectionMatrix = glm::perspective(45.0f, 800.0f/800.0f, 0.1f, 150.0f);

glm::mat4 theOrthographicprojection = glm::ortho(-2.0f, 2.0f, -1.5f, 1.5f, -1.0f, 1.0f);

这是我的对象的坐标。如有必要,只需包括

float vertices[] = { -0.1, -0.1, 2.0,
                      0.1, -0.1, 2.0,
                      0.1, 0.1, 2.0, 
                     -0.1, 0.1, 2.0 };



float vertices2[] = { -0.1,0.1, 2.0,
                      0.1, 0.1, 2.0,
                      0.1, 0.3, 2.0,
                     -0.1, 0.3, 2.0 };


float vertices3[] = {  0.1, 0.1, 2.2,
                       0.1, 0.1, 2.0,
                       0.1, 0.3, 2.0,
                       0.1, 0.3, 2.2 };


float vertices4[] = {  -0.1, 0.1, 2.2,
                       -0.1, 0.1, 2.0,
                       -0.1, 0.3, 2.0,
                       -0.1, 0.3, 2.2 };

unsigned int indices[] = {

0, 1, 2,
2, 3, 0    };

这是您需要查看的我的顶点着色器的一部分。我正在使用制服

void main()
{
    gl_Position = theOrthographicprojection * theprojectionMatrix * 
        vec4(position.x, position.y, position.z, 1.0);
};

标签: c++openglglslglm-math

解决方案


推荐阅读