Add comments and tidying.

This commit is contained in:
David Williams
2014-05-26 16:31:12 +02:00
parent 2a072f9347
commit e9c8daa9cb
2 changed files with 26 additions and 13 deletions

View File

@ -26,27 +26,32 @@ void OpenGLWidget::setShader(QSharedPointer<QGLShaderProgram> shader)
void OpenGLWidget::setViewableRegion(Region viewableRegion)
{
m_viewableRegion = viewableRegion;
// The user has specifed a new viewable region
// so we need to regenerate our camera matrix.
setupWorldToCameraMatrix();
}
void OpenGLWidget::mousePressEvent(QMouseEvent* event)
{
// Initialise these variables which will be used when the mouse actually moves.
m_CurrentMousePos = event->pos();
m_LastFrameMousePos = m_CurrentMousePos;
update();
}
void OpenGLWidget::mouseMoveEvent(QMouseEvent* event)
{
// Update the x and y rotations based on the mouse movement.
m_CurrentMousePos = event->pos();
QPoint diff = m_CurrentMousePos - m_LastFrameMousePos;
m_xRotation += diff.x();
m_yRotation += diff.y();
m_LastFrameMousePos = m_CurrentMousePos;
// The camera rotation has changed so we need to regenerate the matrix.
setupWorldToCameraMatrix();
// Re-render.
update();
}