我正在尝试使用glm设置正交视图矩阵并将其传递给glsl。 this海报有同样的问题,我希望能够渲染距离相机更远的像素,但是当它们距离为1.0时,它们会被剪裁。
MVP矩阵设置如下:
// Setup MVP Matrix
glm::mat4 model = glm::mat4(1.0);
model = glm::translate(model, glm::vec3(sprite->getPositionX(), sprite->getPositionY(), 0.0f));
model = glm::rotate(model, rotation, glm::vec3(0.0f, 0.0f, 1.0f));
model = glm::translate(model, glm::vec3(-sprite->getOffsetX(), -sprite->getOffsetY(), 0.0f));
//model = glm::scale(model, glm::vec3(1.0f, 1.0f, 1.0f)); // Unused for now
glm::mat4 view = glm::lookAt(glm::vec3(0,0,0), glm::vec3(0,0,-1), glm::vec3(0,1,0));
glm::mat4 projection = glm::ortho(0.0f, 800.0f, 600.0f, 0.0f, 1.0f, 1000.0f);
glm::mat4 mvp = projection * view * model;
// Set mpv matrix in shader
GLint mvpLoc = glGetUniformLocation(this->m_shader, "u_mvpMatrix");
glProgramUniformMatrix4fv(this->m_shader, mvpLoc, 1, GL_FALSE, &mvp[0][0]);
我可以看到正在应用平移和旋转渲染的四边形但是当顶点在z轴上只有-1.0f时,它们不会被绘制,当我期望它从-1.0到-1000.0单位之外绘制任何东西时在glm :: ortho的调用中指定。有谁知道如何实现这一目标?