Results 1 to 4 of 4

Thread: zooming

  1. #1
    Guest

    zooming

    How can I convert the x-y coordinates obtained in the glutMouseFunc to world coordinates? I want to allow the user to zoom in on a particular part of the scene, centred on the mouse position clicked; maybe even to select a rectangle within the window to zoom in on. What would be the best way of achieving this?

    Thanks.

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    472

    Re: zooming

    gluUnProject (or selection buffer) - do a search

  3. #3
    Guest

    Re: zooming

    I tried this out, it seems to work *sometimes*, which is definitely bad. What am I doing wrong?

    /*calculate the width, ht & centre of the zoom window*/
    width = maxX - minX;
    ht = maxY - minY;
    cX = minX + width/2;
    cY = minY + ht/2;

    /*get current viewport*/
    glGetIntegerv(GL_VIEWPORT, viewport);

    /*initialise projection mode*/
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    /*zoom in*/
    gluPickMatrix( (GLdouble)cX, (GLdouble)cY,
    (GLdouble)width, (GLdouble)ht, viewport);

    /*multiply perspective matrix by the pick matrix*/
    gluPerspective(90, width/ht, -0.8, 0.;
    glMatrixMode(GL_MODELVIEW);
    glutPostRedisplay();

    Also, how should I decide what values to use for near & far z clipping planes for gluPerspective?

    How can I trace out the picking rectangle drawn by the user as they drag the mouse?(I'm doing this in X)

    Pls help....thanks.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2002
    Location
    Singapore
    Posts
    26

    Re: zooming

    The following website might of some help: http://cheo.resnet.wayne.edu/miguel/

    I remind there is a sample in this website that Zoom In using mouse

Similar Threads

  1. Zooming out
    By Canadian0469 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-19-2008, 01:01 PM
  2. zooming
    By in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-10-2005, 11:29 AM
  3. Zooming in and out
    By SurGL in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-14-2001, 10:57 PM
  4. Zooming
    By KurtCob in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-18-2000, 05:26 AM
  5. zooming
    By Harry of DAIW in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 07-26-2000, 03:07 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean