c++ - 当我将我的着色器与我的 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);
};
解决方案
推荐阅读
- flutter - Flutter 减少 DataTable 中 DataRows 之间的填充
- angular - 扩展运算符执行次数超出预期
- vue.js - vuetify 免费模板主题-博客块级元素
- api - FluentValidator 和 JsonPatchDocument
- kubernetes - kube-apiserver 和代理日志中的错误
- maven - 使用 maven,如何以特定格式将战争的最终名称与项目版本连接起来?
- node.js - 如何在玉视图中只渲染一个文档?
- javascript - Socket.io:相同的图像不连续发送两次
- javascript - 如何在 jQuery Inputmask 中禁止输入减号(-)?
- electron - 以 JS 文件作为参数启动 Electron