| 1 | /* $Id: winpos.c,v 1.2 2000-03-01 18:49:40 jeroen 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 | void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
|
|---|
| 89 | {
|
|---|
| 90 | GLfloat fx, fy;
|
|---|
| 91 |
|
|---|
| 92 | /* Push current matrix mode and viewport attributes */
|
|---|
| 93 | glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
|
|---|
| 94 |
|
|---|
| 95 | /* Setup projection parameters */
|
|---|
| 96 | glMatrixMode( GL_PROJECTION );
|
|---|
| 97 | glPushMatrix();
|
|---|
| 98 | glLoadIdentity();
|
|---|
| 99 | glMatrixMode( GL_MODELVIEW );
|
|---|
| 100 | glPushMatrix();
|
|---|
| 101 | glLoadIdentity();
|
|---|
| 102 |
|
|---|
| 103 | glDepthRange( z, z );
|
|---|
| 104 | glViewport( (int) x - 1, (int) y - 1, 2, 2 );
|
|---|
| 105 |
|
|---|
| 106 | /* set the raster (window) position */
|
|---|
| 107 | fx = x - (int) x;
|
|---|
| 108 | fy = y - (int) y;
|
|---|
| 109 | glRasterPos4f( fx, fy, 0.0, w );
|
|---|
| 110 |
|
|---|
| 111 | /* restore matrices, viewport and matrix mode */
|
|---|
| 112 | glPopMatrix();
|
|---|
| 113 | glMatrixMode( GL_PROJECTION );
|
|---|
| 114 | glPopMatrix();
|
|---|
| 115 |
|
|---|
| 116 | glPopAttrib();
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | #endif
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|