PDA

View Full Version : Mouse Points not displaying right?



09-27-2002, 07:04 PM
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.

mikael_aronsson
09-27-2002, 10:07 PM
Hi !

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

Mikael

09-28-2002, 08:19 PM
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