aboutsummaryrefslogtreecommitdiff
path: root/mesalib/progs/util/winpos.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-10-09 06:31:44 +0000
committermarha <marha@users.sourceforge.net>2009-10-09 06:31:44 +0000
commit06456f5db88b434c3634ede42bdbfdce78fc4249 (patch)
tree97f5174e2d3da40faee7f2ad8858233da3d0166e /mesalib/progs/util/winpos.c
parent7b230a3fe2d6c83488d9eec43067fe8ba8ac081b (diff)
parenta0c4815433ccd57322f4f7703ca35e9ccfa59250 (diff)
downloadvcxsrv-06456f5db88b434c3634ede42bdbfdce78fc4249.tar.gz
vcxsrv-06456f5db88b434c3634ede42bdbfdce78fc4249.tar.bz2
vcxsrv-06456f5db88b434c3634ede42bdbfdce78fc4249.zip
svn merge ^/branches/released . --username marha
Diffstat (limited to 'mesalib/progs/util/winpos.c')
-rw-r--r--mesalib/progs/util/winpos.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/mesalib/progs/util/winpos.c b/mesalib/progs/util/winpos.c
new file mode 100644
index 000000000..5ad98fd27
--- /dev/null
+++ b/mesalib/progs/util/winpos.c
@@ -0,0 +1,42 @@
+/* winpos.c */
+
+
+/*
+ * Set the current raster position to a specific window
+ * coordinate. Also see the GL_MESA_window_pos extension.
+ *
+ * Written by Brian Paul and in the public domain.
+ */
+
+
+void WindowPos( GLfloat x, GLfloat y, GLfloat z )
+{
+ GLfloat fx, fy;
+
+ /* Push current matrix mode and viewport attributes */
+ glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
+
+ /* Setup projection parameters */
+ glMatrixMode( GL_PROJECTION );
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode( GL_MODELVIEW );
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDepthRange( z, z );
+ glViewport( (int) x - 1, (int) y - 1, 2, 2 );
+
+ /* set the raster (window) position */
+ fx = x - (int) x;
+ fy = y - (int) y;
+ glRasterPos3f( fx, fy, 0.0 );
+
+ /* restore matrices, viewport and matrix mode */
+ glPopMatrix();
+ glMatrixMode( GL_PROJECTION );
+ glPopMatrix();
+
+ glPopAttrib();
+}
+