PDA

View Full Version : position



weedus
10-01-2002, 05:20 AM
how can i get the position of my clipping rectangle to recenter where my mouse clicks
on the window. it does move but not to the center, it is always off center
here is my code:

void myMouse( int btn, int st, int mousex, int mousey)
{
/* transform window x and y into world x and y */



mx= (cw/ww) * ( mousex) + a - (cw/2);
my= (-ch/wh)* (mousey) - b + (ch/2);
a=mousex; //update alpha
b=mousey; //and beta


if ( btn==GLUT_LEFT_BUTTON && st == GLUT_DOWN )
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(mx-(cw/2),mx+(cw/2),my-(ch/2),my+(ch/2)); //reset center of clip
glutPostRedisplay();
}

[This message has been edited by weedus (edited 10-01-2002).]

weedus
10-01-2002, 06:16 AM
cw is for clipwidth and ch is clip height
ww-window width
wh-window height

please any suggestions will help