Results 1 to 4 of 4

Thread: Clicking on the screen.

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2001
    Posts
    29

    Clicking on the screen.

    I was wondering if there is an easy way to figure out where, in 3D a user clicked on the screen. I'm using GLUT, so I can easily get the actual (x,y) values, but I need to convert that into OpenGL numbers.

  2. #2
    Junior Member Newbie
    Join Date
    Jan 2001
    Location
    California
    Posts
    22

    Re: Clicking on the screen.

    If you've just clicked in your window at x,y then your coordinates in 3d space will be left_edge_of_vision + (x/window_width)*vision_width, bottom_edge_of_vision + (y/window_height)*vision_height. This is of course ignoring the 'depth' of your click since there wasn't any to be measured.

    It might be time for you to review your algebra/trig. Good luck!

  3. #3
    Member Contributor
    Join Date
    Mar 2001
    Posts
    64

    Re: Clicking on the screen.

    If you are trying to get the depth of something you have already rendered, you could always try this-

    glReadPixels(mouseX,(height-mouseY),1,1,GL_DEPTH_COMPONENT,GL_FLOAT,tmpFloat);

    tmpFloat will contain the depth(0.0-1.0) of wherever you clicked.

    [This message has been edited by Sheepie (edited 05-29-2001).]

  4. #4
    Senior Member Regular Contributor
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    227

    Re: Clicking on the screen.

    do a search on picking in both forums...
    yes

Similar Threads

  1. 2D Mouse Clicking
    By Snickers in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-20-2009, 12:37 PM
  2. Clicking a line
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 09-25-2007, 02:01 PM
  3. Double Clicking
    By razor4077 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-24-2003, 03:18 PM
  4. Clicking out of window
    By tigermain in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-23-2002, 05:24 AM
  5. Mouse Clicking Help Me!!!!!!!!!!!!
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-15-2002, 11:28 PM

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