{
painter.begin(this);
resizeGL(width(),height());
// Rotate the Pyramid and update.
glClearColor(2.0, 2.0, 2.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslated(0.0, 0.0,-10.0);
glRotated(m_nXRot / 10.0, 2.0, 0.0, 0.0);
glRotated(m_nYRot / 10.0, 0.0, 2.0, 0.0);
glRotated(m_nZRot / 10.0, 0.0, 0.0, 2.0);
glCallList(m_glObject);
event->accept();
}
and the resizeGL() is
void QPyramidTool::resizeGL(int width, int height)
{
int side = qMin(width, height);
glViewport((width - side) / 2, (height - side) / 2, side, side);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.5, +3.5, +3.5, -3.5, 4.0, 20.0);
glMatrixMode(GL_MODELVIEW);
}
void QPyramidTool::paintEvent(QPaintEvent *event)
{
QPainter painter;
painter.begin(this);
resizeGL(width(),height());
// Rotate the Pyramid and update.
glClearColor(2.0, 2.0, 2.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslated(0.0, 0.0,-10.0);
glRotated(m_nXRot / 10.0, 2.0, 0.0, 0.0);
glRotated(m_nYRot / 10.0, 0.0, 2.0, 0.0);
glRotated(m_nZRot / 10.0, 0.0, 0.0, 2.0);
glCallList(m_glObject);
event->accept();
}
and the resizeGL() is
void QPyramidTool::resizeGL(int width, int height)
{
int side = qMin(width, height);
glViewport((width - side) / 2, (height - side) / 2, side, side);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-3.5, +3.5, +3.5, -3.5, 4.0, 20.0);
glMatrixMode(GL_MODELVIEW);
}
To copy to clipboard, switch view to plain text mode
Bookmarks