Results 1 to 2 of 2

Thread: Qt-OpenGL Zoom Problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default Qt-OpenGL Zoom Problem

    Dear Friends
    I am suceessfully able to zoom in/out in Qt application but on opengl graphics.
    For zooming I am using the steps as 0.2 and intializing the zoomFactor = 1.0.
    But When the value gets lower than 0.2 the it's getting out of visibility.

    What kind of steps should I use so that it zooms properly as long as the object is present.
    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    static float steps = 1.0
    MyGlWidget::mouseMoveEvent(QMouseEvent *me)
    {
    if(me->button()==Qt::RightButton)
    {
    if(me->y() > lastPos.y())
    {
    //zoom in
    zoomFactor -= steps;
    if(zoomFactor <0)
    zoomFactor = 0.0;
    if(zoomFactor > 6.0)
    zoomFactor = 6.0;
    setProjection(width(),height());
    }
    }
    }
    MyGlWidget::setProjection(int w, int h)
    {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(30*zoomFactor,(GLfloat)w/(GLfloat)h,1.0,100.0);
    glMatrixMode(GL_MODELVIEW);
    updateGL();
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////
    // This code is zooming in but the zoomfactor starts from 1.0 and goes upto 0.2 after 0.2 it just disappears from the screen

    // how can I control this steps so that as it gets closer the zoomFactor should slow down
    //and we can see larger onto the core of the object.
    //
    //Any help would be appreciated !

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt-OpenGL Zoom Problem

    Hi!

    The first parameter to gluperspective is the vertical angle in degrees spanned between the camera position and the near planes borders.

    Have a look at the projection tutor here: http://www.xmission.com/~nate/tutors.html

    I don't think, that the FOV parameter is supposed to be lower than 1. If you need more zoom, just move your camera closer to the model. You can use gluLookAt(cam.position,cam.lookat,upvector) for that.

    This topic is not quite Qt related.. You might find better suited forums for opengl specific questions..

    Johannes

Similar Threads

  1. Replies: 1
    Last Post: 2nd September 2009, 14:07
  2. Qt OpenGL ES
    By ^NyAw^ in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2009, 11:21
  3. problem in rendering opengl on QGraphicsView
    By Sandip in forum Qt Programming
    Replies: 17
    Last Post: 15th April 2008, 08:27
  4. Graphics view display problem.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2007, 07:08
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.