st/xorg: Include cursorstr.h
[mesa.git] / progs / util / winpos.c
1 /* winpos.c */
2
3
4 /*
5 * Set the current raster position to a specific window
6 * coordinate. Also see the GL_MESA_window_pos extension.
7 *
8 * Written by Brian Paul and in the public domain.
9 */
10
11
12 void WindowPos( GLfloat x, GLfloat y, GLfloat z )
13 {
14 GLfloat fx, fy;
15
16 /* Push current matrix mode and viewport attributes */
17 glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
18
19 /* Setup projection parameters */
20 glMatrixMode( GL_PROJECTION );
21 glPushMatrix();
22 glLoadIdentity();
23 glMatrixMode( GL_MODELVIEW );
24 glPushMatrix();
25 glLoadIdentity();
26
27 glDepthRange( z, z );
28 glViewport( (int) x - 1, (int) y - 1, 2, 2 );
29
30 /* set the raster (window) position */
31 fx = x - (int) x;
32 fy = y - (int) y;
33 glRasterPos3f( fx, fy, 0.0 );
34
35 /* restore matrices, viewport and matrix mode */
36 glPopMatrix();
37 glMatrixMode( GL_PROJECTION );
38 glPopMatrix();
39
40 glPopAttrib();
41 }
42