Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Mouse Points not displaying right?

  1. #1
    Guest

    Mouse Points not displaying right?

    I've written some code where the user clicks on the screen with the mouse, and a dot is drawn where they click. However, the dots don't appear at the right location - in fact, regardless of where I click, the dots always seem to form a straight line pointing from southwest to northeast.

    I've already converted the mouse coordinates to "world coordinates" using the following -
    is there a reason why this is happening?

    x = (vx-winWidth/2 )/(double)100.0 + 0.5;

    y = (winHeight/2-vy)/(double)100.0 + 0.5;

    Thanks in advance.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,651

    Re: Mouse Points not displaying right?

    Hi !

    I am assuming that we are talking OpenGL here right ?, in that case how is your projection matrix setup ?

    Mikael

  3. #3
    Guest

    Re: Mouse Points not displaying right?

    Hello, thanks for your reply. Yes, it's OpenGL I'm having problems with. I think below is the projection matrix:

    void setCamera() {

    glViewport(0,0, winWidth,winHeight);

    glMatrixMode(GL_PROJECTION);

    glLoadIdentity();

    gluOrtho2D(-winWidth /2/pixPerMeter, winWidth /2/pixPerMeter,
    -winHeight/2/pixPerMeter, winHeight/2/pixPerMeter);

    }


    Originally posted by mikael_aronsson:
    Hi !

    I am assuming that we are talking OpenGL here right ?, in that case how is your projection matrix setup ?

    Mikael

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •