Results 1 to 4 of 4

Thread: Can't get gluProject and SetCursorPos to work together.

  1. #1
    Guest

    Can't get gluProject and SetCursorPos to work together.

    Ok so I got a 3d coordinate and i want the 2d coordinates so I can move my mouse cursor there but I'm having some troubles. First I do gluProject and looking at the logs I get accurate x,y values but when I use SetCursorPos to move the mouse there it will kinda overshoot and move it too far. For example if my mouse is currently below the 3d object and I try to move the mouse to the 2d x,y the mouse will be moved above the 3d object. The same with when the mouse is to the right, it will be moved too far to the left. Neither function reutrned errors so I have no clue why it's doing this. It seems the poblem is in SetCursorPos but I'm not sure. I'm doing this in C++. Any help is GREATLY appreciated, it's been bugging me for months. Thx.

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

    Re: Can't get gluProject and SetCursorPos to work together.

    Usually mouse position is given by

    (x, height - y)

    You may also be trying to set the mouse cursor in relationship to the desktop rather than the client area of the screen....

  3. #3
    Guest

    Re: Can't get gluProject and SetCursorPos to work together.

    Yes I was using height-y because the opengl coordinate system is different than the coordinate system for the mouse. The problem still presists.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2002
    Location
    Linz, Austria
    Posts
    9

    Re: Can't get gluProject and SetCursorPos to work together.

    Originally posted by toon:
    Ok so I got a 3d coordinate and i want the 2d coordinates so I can move my mouse cursor there but I'm having some troubles. First I do gluProject and looking at the logs I get accurate x,y values but when I use SetCursorPos to move the mouse there it will kinda overshoot and move it too far. For example if my mouse is currently below the 3d object and I try to move the mouse to the 2d x,y the mouse will be moved above the 3d object. The same with when the mouse is to the right, it will be moved too far to the left. Neither function reutrned errors so I have no clue why it's doing this. It seems the poblem is in SetCursorPos but I'm not sure. I'm doing this in C++. Any help is GREATLY appreciated, it's been bugging me for months. Thx.

    are you using glut?
    if not, and you are using windows, you should think of coordinate transformation a la ClientToScreen/ScreenToClient to move your coordinates into the correct window offset

    hope this helps...

Similar Threads

  1. gluProject
    By HellKnight in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 12-02-2006, 04:29 PM
  2. gluProject behind me
    By evil in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 02-26-2003, 06:44 AM
  3. gluProject()
    By schailan in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 09-09-2002, 05:41 AM
  4. gluProject
    By MasTrO in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 03-18-2002, 07:08 AM
  5. gluProject (yes, yet again)
    By Super-K in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-16-2002, 05:30 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