我在更新屏幕上的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