PDA

View Full Version : Specifiying the View Origin of GLUT window



kabrit
01-02-2002, 05:02 AM
When I create a window with the glut libraiies and use the mouse function, the xy-coordinates increment from the top of the window to the bottom of the window as if they where in a text mode. I would like to know how I can reallign the origin of the window so that the xy-coordinates can be alligned with [0,0] as the center of the window?

thebamaman
01-02-2002, 10:19 AM
Originally posted by kabrit:
When I create a window with the glut libraiies and use the mouse function, the xy-coordinates increment from the top of the window to the bottom of the window as if they where in a text mode. I would like to know how I can reallign the origin of the window so that the xy-coordinates can be alligned with [0,0] as the center of the window?

I don't think glut will do this for you, but you could either write a small function that interpolates the mouse coordinates into the coordinates you want, or just put this small bit of code at the beginning of the mouse function registered as your call back. Kind of like this:

void mouse(..., int x, int y) {
int ix, iy; //interpolated coords
int left = -width/2;
int bottom = -height/2;

ix = x+left;
iy = (height-y)+bottom;

//now use ix, iy instead of x, y
}

Hope I helped.

[This message has been edited by thebamaman (edited 01-02-2002).]