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.

Hi !

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

Mikael

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:
[b]Hi !

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

Mikael[/b]