我在更新屏幕上的OpenGL模型時遇到問題。我使用定時器來更新旋轉角度的每一步計時器:帶QTimer的updateGL()
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(Spin()));
timer->start(500);
void GLWidget::Spin()
{
qDebug() << "Spin()";
rotationX += 5;
rotationY += 5;
rotationZ += 5;
updateGL();
}
我也試着更新()而不是updateGL(),但它也不起作用。 奇怪的是,該模型用鼠標旋轉,它的工作:
void GLWidget::mouseMoveEvent(QMouseEvent *event)
{
GLfloat dx = GLfloat(event->x() - lastPos.x())/width();
GLfloat dy = GLfloat(event->y() - lastPos.y())/height();
if (event->buttons() & Qt::LeftButton) {
rotationX += 180 * dy;
rotationY += 180 * dx;
updateGL();
} else if (event->buttons() & Qt::RightButton) {
rotationX += 180 * dy;
rotationZ += 180 * dx;
updateGL();
}
lastPos = event->pos();
}
使用update()不updateGL() – paulm 2014-01-05 02:27:25