1 | /* $Id: winpos.c,v 1.1 2000-02-29 00:50:15 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.1
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | */
|
---|
26 | /* $XFree86: xc/lib/GL/mesa/src/winpos.c,v 1.2 1999/04/04 00:20:36 dawes Exp $ */
|
---|
27 |
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * GL_MESA_window_pos extension
|
---|
34 | *
|
---|
35 | * This extension offers a set of functions named glWindowPos*MESA() which
|
---|
36 | * directly set the current raster position to the given window coordinate.
|
---|
37 | * glWindowPos*MESA() are similar to glRasterPos*() but bypass the
|
---|
38 | * modelview, projection and viewport transformations.
|
---|
39 | *
|
---|
40 | * These functions should be very handy in conjunction with glDrawPixels()
|
---|
41 | * and glCopyPixels().
|
---|
42 | *
|
---|
43 | * If your application uses glWindowPos*MESA() and may be compiled with
|
---|
44 | * a real OpenGL instead of Mesa you can simply copy the winpos.[ch] files
|
---|
45 | * into your source tree and compile them with the rest of your code
|
---|
46 | * since glWindowPos*MESA() can, and is, implemented in terms of standard
|
---|
47 | * OpenGL commands when not using Mesa. In your source files which use
|
---|
48 | * glWindowPos*MESA() just #include "winpos.h".
|
---|
49 | */
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | #ifdef PC_HEADER
|
---|
54 | #include "all.h"
|
---|
55 | #else
|
---|
56 | #include "gl.h"
|
---|
57 | #endif
|
---|
58 |
|
---|
59 | #ifdef GL_MESA_window_pos
|
---|
60 |
|
---|
61 |
|
---|
62 | #ifndef PC_HEADER
|
---|
63 | #ifdef XFree86Server
|
---|
64 | #include "GL/xf86glx.h"
|
---|
65 | #endif
|
---|
66 | #include "rastpos.h"
|
---|
67 | #include "winpos.h"
|
---|
68 | #endif
|
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 | /*
|
---|
73 | * Mesa implementation of glWindowPos*MESA()
|
---|
74 | */
|
---|
75 | void gl_WindowPos4fMESA( GLcontext *ctx,
|
---|
76 | GLfloat x, GLfloat y, GLfloat z, GLfloat w )
|
---|
77 | {
|
---|
78 | gl_windowpos( ctx, x, y, z, w );
|
---|
79 | }
|
---|
80 |
|
---|
81 |
|
---|
82 | #else
|
---|
83 |
|
---|
84 |
|
---|
85 | /*
|
---|
86 | * OpenGL implementation of glWindowPos*MESA()
|
---|
87 | */
|
---|
88 | /* FIX: JvdH - was glWindowPos4fMESA */
|
---|
89 | void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
|
---|
90 | {
|
---|
91 | GLfloat fx, fy;
|
---|
92 |
|
---|
93 | /* Push current matrix mode and viewport attributes */
|
---|
94 | glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
|
---|
95 |
|
---|
96 | /* Setup projection parameters */
|
---|
97 | glMatrixMode( GL_PROJECTION );
|
---|
98 | glPushMatrix();
|
---|
99 | glLoadIdentity();
|
---|
100 | glMatrixMode( GL_MODELVIEW );
|
---|
101 | glPushMatrix();
|
---|
102 | glLoadIdentity();
|
---|
103 |
|
---|
104 | glDepthRange( z, z );
|
---|
105 | glViewport( (int) x - 1, (int) y - 1, 2, 2 );
|
---|
106 |
|
---|
107 | /* set the raster (window) position */
|
---|
108 | fx = x - (int) x;
|
---|
109 | fy = y - (int) y;
|
---|
110 | glRasterPos4f( fx, fy, 0.0, w );
|
---|
111 |
|
---|
112 | /* restore matrices, viewport and matrix mode */
|
---|
113 | glPopMatrix();
|
---|
114 | glMatrixMode( GL_PROJECTION );
|
---|
115 | glPopMatrix();
|
---|
116 |
|
---|
117 | glPopAttrib();
|
---|
118 | }
|
---|
119 |
|
---|
120 |
|
---|
121 | #endif
|
---|
122 |
|
---|
123 |
|
---|
124 |
|
---|