Results 1 to 2 of 2

Thread: Pixel coordinates with gluPerspective

  1. #1
    Guest

    Pixel coordinates with gluPerspective

    When using glOrtho2D( ), my mouse handler would return an int x, y position of the mouse click.

    I could then set the pixel at that point to a particular color, etc.

    I am trying 3D drawing now, with the following:

    glViewport (0, 0, 500, 500);
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    gluPerspective(65.0, (GLfloat) 500/ (GLfloat) 500, 1.0, 20.0);
    gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

    Now, when i click the window with my mouse, I still get integer coordinates - but they can no longer be displayed on the window.

    The problem is that the scaling has changed, so that plotting (0,0,0) is at the center of the window, and (1,0,0) is about an inch to the right of the origin - instead of just one pixel to the right.

    Is there any way at all to use mouse coordinates with the perspective projection functions?

    Thanks
    chetty

  2. #2
    Guest

    Re: Pixel coordinates with gluPerspective

    Okay ... found the answer ... gluUnProject( )

    Now I need to make it work in my program (!)

    Thanks to past posters who ran into the same issue

Similar Threads

  1. Texture coordinates to screen pixel coordinates
    By lucafr in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-13-2011, 04:19 AM
  2. Replies: 0
    Last Post: 09-11-2008, 12:15 PM
  3. gluPerspective and windows coordinates
    By CactusBlip in forum OpenGL: General
    Replies: 2
    Last Post: 09-07-2007, 12:20 AM
  4. Model coordinates match pixel coordinates
    By timmeh in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-22-2006, 10:50 AM
  5. 3D coordinates of a pixel
    By aguion in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-09-2004, 02:55 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