updated the basic qt opengl example to support qt 5.0 ways of managing coords

(simply use the new QT2VCG_X/Y helper functions to translate mouse events)
This commit is contained in:
Paolo Cignoni 2013-12-13 07:57:08 +00:00
parent 276438958f
commit fc047dbe3f
1 changed files with 56 additions and 56 deletions

View File

@ -105,7 +105,7 @@ void GLArea::paintGL ()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40, GLArea::width()/(float)GLArea::height(), 0.1, 100);
gluPerspective(25, GLArea::width()/(float)GLArea::height(), 0.1, 100);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,5, 0,0,0, 0,1,0);
@ -114,7 +114,7 @@ void GLArea::paintGL ()
track.GetView();
track.Apply();
glPushMatrix();
float d=1.0f/mesh.bbox.Diag();
float d=2.0f/mesh.bbox.Diag();
vcg::glScale(d);
glTranslate(-glWrap.m->bbox.Center());
// the trimesh drawing calls
@ -174,21 +174,21 @@ void GLArea::mousePressEvent (QMouseEvent * e)
{
e->accept ();
setFocus ();
track.MouseDown (e->x (), height () - e->y (), QT2VCG (e->button (), e->modifiers ()));
track.MouseDown (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
updateGL ();
}
void GLArea::mouseMoveEvent (QMouseEvent * e)
{
if (e->buttons ()) {
track.MouseMove (e->x (), height () - e->y ());
track.MouseMove (QT2VCG_X(this,e), QT2VCG_Y(this,e));
updateGL ();
}
}
void GLArea::mouseReleaseEvent (QMouseEvent * e)
{
track.MouseUp (e->x (), height () - e->y (), QT2VCG (e->button (), e->modifiers ()));
track.MouseUp (QT2VCG_X(this,e), QT2VCG_Y(this,e), QT2VCG (e->button (), e->modifiers ()));
updateGL ();
}