我正在尝试获取立方体的正面和背面并将它们保存到纹理以计算它们的差异。
这就是我想要的。
我有这样的paintGL(),
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glShadeModel(GL_SMOOTH);
QMatrix4x4 mMatrix;
QMatrix4x4 vMatrix;
QMatrix4x4 cameraTransformation;
cameraTransformation.rotate(alpha, 0, 1, 0);
cameraTransformation.rotate(beta, 1, 0, 0);
QVector3D cameraPosition = cameraTransformation * QVector3D(0, 0, distance);
QVector3D cameraUpDirection = cameraTransformation * QVector3D(0, 1, 0);
QVector3D eye = QVector3D(0, 0, 0);
vMatrix.lookAt(cameraPosition, eye, cameraUpDirection);
shaderProgram.bind();
shaderProgram.setUniformValue("mvpMatrix", pMatrix*vMatrix*mMatrix);
//vertex array enable
shaderProgram.setAttributeArray("vertex", vertices.constData());
shaderProgram.enableAttributeArray("vertex");
//color array enable
shaderProgram.setAttributeArray("color", colors.constData());
shaderProgram.enableAttributeArray("color");
/ /glDisable(GL_DEPTH_TEST);
glDrawArrays(GL_QUADS, 0, vertices.size());
//vertex&color array disable
shaderProgram.disableAttributeArray("vertex");
shaderProgram.disableAttributeArray("color");
shaderProgram.release();
}