我正在尝试使用NVIDIA Quadro 5000上的立体3D渲染绘制从.obj文件加载的基本网格。据我所知,我认为我的左眼和右眼视锥和偏移设置相应,但我的主要问题是写入和清除BACK_LEFT和BACK_RIGHT缓冲区。它似乎完全错过了第一部分,只绘制了BACK_RIGHT缓冲区(渲染循环的第二部分)。如果我能得到一些关于如何在同一帧中写入/读取和清除这些缓冲区的指针,那将是很好的。这是一个Linux应用程序,因此glXSwap(),不使用过剩或glew并使用glm进行数学运算。这是我的绘图循环:
void GLDraw::Draw()
{
//initialise shader in frame
shader->UseShaderProgram();
//select back_left buffer
glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//set projection and view for back_left
projectionMatrix = glm::frustum(-xCoord - frustumAssymmetry, xCoord - frustumAssymmetry, -yCoord, yCoord, 0.1f, 200.0f);
projectionMatrix *= glm::translate(glm::mat4(1.0f), glm::vec3(eyeOffset, 0.0f, 0.0f));
glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, value_ptr(projectionMatrix));
glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, &viewMatrix[0][0]);
//set model matrix for rendering calls
modelMatrix = scale(mat4(1.0f), vec3(0.7, 0.7, 0.5f));
modelMatrix *= translate(mat4(1.0f), vec3(0.0f, 0.0f, 0.0f));
modelMatrix *= rotate(mat4(1.0f), i+=0.04, vec3(0.0f, 1.0f, 0.0f));
glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, &modelMatrix[0][0]);
//draw VAO
glBindVertexArray(vikingVAO);
glDrawElements(GL_TRIANGLES, viking_elements.size() * sizeof(viking_elements[0]), GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
//select back_right buffer <-- SEEMS TO ONLY RENDER FROM HERE, MISSING THE FIRST PART
glDrawBuffer(GL_BACK_RIGHT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//set projection and view for back_right
projectionMatrix = glm::frustum(-xCoord + frustumAssymmetry, xCoord + frustumAssymmetry, -yCoord, yCoord, 0.1f, 200.0f);
projectionMatrix *= glm::translate(glm::mat4(1.0f), glm::vec3(-eyeOffset, 0.0f, 0.0f));
glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, value_ptr(projectionMatrix));
glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, &viewMatrix[0][0]);
//set model matrix for rendering calls
modelMatrix = scale(mat4(1.0f), vec3(0.7, 0.7, 0.5f));
modelMatrix *= translate(mat4(1.0f), vec3(0.0f, 0.0f, 0.0f));
modelMatrix *= rotate(mat4(1.0f), i+=0.04, vec3(0.0f, 1.0f, 0.0f));
glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, &modelMatrix[0][0]);
//draw VAO
glBindVertexArray(vikingVAO);
glDrawElements(GL_TRIANGLES, viking_elements.size() * sizeof(viking_elements[0]), GL_UNSIGNED_SHORT, 0);
glBindVertexArray(0);
//clear shader
shader->ClearShaderProgram();
//swap buffers
glXSwapBuffers(display, win);
}
编辑:意识到如果我在右侧屏幕上运行我的应用程序,它会渲染GL_BACK_RIGHT缓冲区。在左侧屏幕上运行它将绘制GL_BACK_LEFT。
有什么想法吗?监控设置可能吗?