Results 1 to 3 of 3

Thread: Mouse interacting

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    21

    Mouse interacting

    Let's say there are a bunch of points visible on the screen.
    How do make OpenGL let you choose one of them by mouse-click, and move it around the screen as you hold down a mouse-button, then realease and let it stay so I can choose another point? I don't think I have fully understood the interaction between 'mouseFunc' and 'motionFunc'. It seems like the mouse- and screen-coordinates are a bit out of tune, by the way. If I enlarge the OpenGL-screen the tuning-problem gets worse.

    Anybody?

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    7

    Re: Mouse interacting

    You will need to do "picking and selection" to be able to determine when the mouse has selected an object.
    This is a little complicated (and probably can't be answered fully via this board).
    I suggest you get (if you don't have) or read (if you do have) the Red Book. I believe that there is a whole section on picking and selection.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: Mouse interacting

    here's the low down on glut's mouse callback functions:

    void mouse(int button, int state, int x, int y)
    button: either GLUT_LEFT_BUTTON, GLUT_RIGHT_BUTTON, GLUT_MIDDLE_BUTTON
    state: GLUT_UP or GLUT_DOWN
    x and y: window coords of mouse at time of callback

    this function is good for getting initial mouse coordinates. it will only be called when the state of a mouse button changes from up to down, or down to up.

    void passivemotion(int x, int y)
    x and y: window coords of mouse at time of callback

    this function gets called whenever the mouse moves WITHIN the window and a button is NOT pressed. this guy is the one you'd use to simulate a Quake-style mouse look feature.

    void motion(int x, int y)
    x and y: window coords of mouse at time of callback

    this function is identical to passive motion except it gets called when the mouse moves and a button is pressed. you would need to set a global variable in the mouse() func above to be able to tell which button is pressed so it can be processed correctly in the motion() func. hope that helps

    b

Similar Threads

  1. othographic and perspective projections interacting?
    By bsabiston in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-12-2012, 06:37 AM
  2. Multiple light sources interacting
    By leftblank in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-26-2012, 06:35 PM
  3. Interacting with individual parts of a model
    By Dave Nott in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-15-2010, 09:50 AM
  4. how keep rendering whilst interacting with console
    By ooIsNotMyThing in forum OpenGL: General
    Replies: 7
    Last Post: 01-05-2010, 07:39 AM
  5. rotate on mouse click and drag in the direction of the mouse cursor
    By vamsee kanth in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-02-2005, 09:54 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