PDA

View Full Version : Using raster graphics to display a mouse pointer



dodgyposse
09-05-2000, 04:19 AM
I have the origins of a 3d engine working now, but in order to start on my game, I need to be able to display dialogs, and the mouse pointer using opengls raster graphics
primitives.

My problem is this:

The glRasterPos2f function accepts x and y world coordinates, not screen/viewport pixels.

How do I convert between the two?

I want to display a pixmap at MouseX,MouseY,
and therefore need to perform this conversion.

dd

Bob
09-05-2000, 04:37 AM
Push the old projection matrix, and setup a new, orthographic one.




glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity()
gluOrtho2D(0, window_height, 0, window_width);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

// no you can set all rasterposition s in screen coordinates, with z in the range [1.0, -1.0]

glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);


Not 100% sure about the code, came up with it at the same time I wrote this message.