| 1 | /* $Id: xmesa.h,v 1.1 2000-02-29 00:43:33 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 |
|
|---|
| 27 |
|
|---|
| 28 | /*
|
|---|
| 29 | * $Log: xmesa.h,v $
|
|---|
| 30 | * Revision 1.1 2000-02-29 00:43:33 sandervl
|
|---|
| 31 | * created
|
|---|
| 32 | *
|
|---|
| 33 | * Revision 1.1.1.1.2.2 1999/12/13 21:54:19 brianp
|
|---|
| 34 | * applied Daryll's patches
|
|---|
| 35 | *
|
|---|
| 36 | * Revision 1.1.1.1.2.1 1999/11/24 18:41:37 brianp
|
|---|
| 37 | * bumped version to 3.1
|
|---|
| 38 | *
|
|---|
| 39 | * Revision 1.1.1.1 1999/08/19 00:55:40 jtg
|
|---|
| 40 | * Imported sources
|
|---|
| 41 | *
|
|---|
| 42 | * Revision 1.3 1999/02/24 22:43:27 jens
|
|---|
| 43 | * Name changes to get XMesa to compile standalone inside XFree86
|
|---|
| 44 | *
|
|---|
| 45 | * Revision 1.2 1999/02/14 03:39:09 brianp
|
|---|
| 46 | * new copyright
|
|---|
| 47 | *
|
|---|
| 48 | * Revision 1.1 1998/02/13 03:17:32 brianp
|
|---|
| 49 | * Initial revision
|
|---|
| 50 | *
|
|---|
| 51 | */
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | /*
|
|---|
| 55 | * Mesa/X11 interface. This header file serves as the documentation for
|
|---|
| 56 | * the Mesa/X11 interface functions.
|
|---|
| 57 | *
|
|---|
| 58 | * Note: this interface isn't intended for user programs. It's primarily
|
|---|
| 59 | * just for implementing the pseudo-GLX interface.
|
|---|
| 60 | */
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | /* Sample Usage:
|
|---|
| 64 |
|
|---|
| 65 | In addition to the usual X calls to select a visual, create a colormap
|
|---|
| 66 | and create a window, you must do the following to use the X/Mesa interface:
|
|---|
| 67 |
|
|---|
| 68 | 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
|
|---|
| 69 |
|
|---|
| 70 | 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
|
|---|
| 71 | the XMesaVisual.
|
|---|
| 72 |
|
|---|
| 73 | 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
|
|---|
| 74 | and XMesaVisual.
|
|---|
| 75 |
|
|---|
| 76 | 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
|
|---|
| 77 | to make the context the current one.
|
|---|
| 78 |
|
|---|
| 79 | 5. Make gl* calls to render your graphics.
|
|---|
| 80 |
|
|---|
| 81 | 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
|
|---|
| 82 |
|
|---|
| 83 | 7. Before the X window is destroyed, call XMesaDestroyBuffer().
|
|---|
| 84 |
|
|---|
| 85 | 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
|
|---|
| 86 |
|
|---|
| 87 | See the demos/xdemo.c and xmesa1.c files for examples.
|
|---|
| 88 | */
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | #ifndef XMESA_H
|
|---|
| 94 | #define XMESA_H
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | #ifdef __cplusplus
|
|---|
| 98 | extern "C" {
|
|---|
| 99 | #endif
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 | #ifdef XFree86Server
|
|---|
| 103 | #include "xmesa_xf86.h"
|
|---|
| 104 | #else
|
|---|
| 105 | #include <X11/Xlib.h>
|
|---|
| 106 | #include <X11/Xutil.h>
|
|---|
| 107 | #include "xmesa_x.h"
|
|---|
| 108 | #ifdef GLX_DIRECT_RENDERING
|
|---|
| 109 | #include "dri_mesa.h"
|
|---|
| 110 | #endif
|
|---|
| 111 | #endif
|
|---|
| 112 | #include "GL/gl.h"
|
|---|
| 113 |
|
|---|
| 114 | #ifdef AMIWIN
|
|---|
| 115 | #include <pragmas/xlib_pragmas.h>
|
|---|
| 116 | extern struct Library *XLibBase;
|
|---|
| 117 | #endif
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | #define XMESA_MAJOR_VERSION 3
|
|---|
| 121 | #define XMESA_MINOR_VERSION 1
|
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | /*
|
|---|
| 126 | * Values passed to XMesaGetString:
|
|---|
| 127 | */
|
|---|
| 128 | #define XMESA_VERSION 1
|
|---|
| 129 | #define XMESA_EXTENSIONS 2
|
|---|
| 130 |
|
|---|
| 131 |
|
|---|
| 132 | /*
|
|---|
| 133 | * Values passed to XMesaSetFXmode:
|
|---|
| 134 | */
|
|---|
| 135 | #define XMESA_FX_WINDOW 1
|
|---|
| 136 | #define XMESA_FX_FULLSCREEN 2
|
|---|
| 137 |
|
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 | typedef struct xmesa_context *XMesaContext;
|
|---|
| 141 |
|
|---|
| 142 | typedef struct xmesa_visual *XMesaVisual;
|
|---|
| 143 |
|
|---|
| 144 | typedef struct xmesa_buffer *XMesaBuffer;
|
|---|
| 145 |
|
|---|
| 146 | #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
|
|---|
| 147 | /*
|
|---|
| 148 | * Initialize the XMesa driver.
|
|---|
| 149 | */
|
|---|
| 150 | extern GLboolean XMesaInitDriver( __DRIscreenPrivate *driScrnPriv );
|
|---|
| 151 |
|
|---|
| 152 | /*
|
|---|
| 153 | * Reset the XMesa driver when the X server resets.
|
|---|
| 154 | */
|
|---|
| 155 | extern void XMesaResetDriver( __DRIscreenPrivate *driScrnPriv );
|
|---|
| 156 | #endif
|
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 | /*
|
|---|
| 160 | * Create a new X/Mesa visual.
|
|---|
| 161 | * Input: display - X11 display
|
|---|
| 162 | * visinfo - an XVisualInfo pointer
|
|---|
| 163 | * rgb_flag - GL_TRUE = RGB mode,
|
|---|
| 164 | * GL_FALSE = color index mode
|
|---|
| 165 | * alpha_flag - alpha buffer requested?
|
|---|
| 166 | * db_flag - GL_TRUE = double-buffered,
|
|---|
| 167 | * GL_FALSE = single buffered
|
|---|
| 168 | * stereo_flag - stereo visual?
|
|---|
| 169 | * depth_size - requested bits/depth values, or zero
|
|---|
| 170 | * stencil_size - requested bits/stencil values, or zero
|
|---|
| 171 | * accum_size - requested bits/component values, or zero
|
|---|
| 172 | * ximage_flag - GL_TRUE = use an XImage for back buffer,
|
|---|
| 173 | * GL_FALSE = use an off-screen pixmap for back buffer
|
|---|
| 174 | * Return; a new XMesaVisual or 0 if error.
|
|---|
| 175 | */
|
|---|
| 176 | extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
|
|---|
| 177 | XMesaVisualInfo visinfo,
|
|---|
| 178 | GLboolean rgb_flag,
|
|---|
| 179 | GLboolean alpha_flag,
|
|---|
| 180 | GLboolean db_flag,
|
|---|
| 181 | GLboolean stereo_flag,
|
|---|
| 182 | GLboolean ximage_flag,
|
|---|
| 183 | GLint depth_size,
|
|---|
| 184 | GLint stencil_size,
|
|---|
| 185 | GLint accum_size,
|
|---|
| 186 | GLint level );
|
|---|
| 187 |
|
|---|
| 188 | /*
|
|---|
| 189 | * Destroy an XMesaVisual, but not the associated XVisualInfo.
|
|---|
| 190 | */
|
|---|
| 191 | extern void XMesaDestroyVisual( XMesaVisual v );
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | /*
|
|---|
| 196 | * Create a new XMesaContext for rendering into an X11 window.
|
|---|
| 197 | *
|
|---|
| 198 | * Input: visual - an XMesaVisual
|
|---|
| 199 | * share_list - another XMesaContext with which to share display
|
|---|
| 200 | * lists or NULL if no sharing is wanted.
|
|---|
| 201 | * Return: an XMesaContext or NULL if error.
|
|---|
| 202 | */
|
|---|
| 203 | extern XMesaContext XMesaCreateContext( XMesaVisual v,
|
|---|
| 204 | XMesaContext share_list
|
|---|
| 205 | #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
|
|---|
| 206 | , __DRIcontextPrivate *driContextPriv
|
|---|
| 207 | #endif
|
|---|
| 208 | );
|
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 | /*
|
|---|
| 212 | * Destroy a rendering context as returned by XMesaCreateContext()
|
|---|
| 213 | */
|
|---|
| 214 | extern void XMesaDestroyContext( XMesaContext c );
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 | /*
|
|---|
| 218 | * Create an XMesaBuffer from an X window.
|
|---|
| 219 | */
|
|---|
| 220 | extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
|
|---|
| 221 | XMesaWindow w
|
|---|
| 222 | #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
|
|---|
| 223 | , __DRIdrawablePrivate *driDrawPriv
|
|---|
| 224 | #endif
|
|---|
| 225 | );
|
|---|
| 226 |
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 | /*
|
|---|
| 230 | * Create an XMesaBuffer from an X pixmap.
|
|---|
| 231 | */
|
|---|
| 232 | extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
|
|---|
| 233 | XMesaPixmap p,
|
|---|
| 234 | XMesaColormap cmap
|
|---|
| 235 | #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
|
|---|
| 236 | , __DRIdrawablePrivate *driDrawPriv
|
|---|
| 237 | #endif
|
|---|
| 238 | );
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 |
|
|---|
| 242 | /*
|
|---|
| 243 | * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
|
|---|
| 244 | */
|
|---|
| 245 | extern void XMesaDestroyBuffer( XMesaBuffer b );
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 | /*
|
|---|
| 249 | * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
|
|---|
| 250 | *
|
|---|
| 251 | * New in Mesa 2.3.
|
|---|
| 252 | */
|
|---|
| 253 | extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
|
|---|
| 254 | XMesaDrawable d );
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 | /*
|
|---|
| 259 | * Bind a buffer to a context and make the context the current one.
|
|---|
| 260 | */
|
|---|
| 261 | extern GLboolean XMesaMakeCurrent( XMesaContext c,
|
|---|
| 262 | XMesaBuffer b );
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 | /*
|
|---|
| 266 | * Return a handle to the current context.
|
|---|
| 267 | */
|
|---|
| 268 | extern XMesaContext XMesaGetCurrentContext( void );
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 | /*
|
|---|
| 272 | * Return handle to the current buffer.
|
|---|
| 273 | */
|
|---|
| 274 | extern XMesaBuffer XMesaGetCurrentBuffer( void );
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 | /*
|
|---|
| 278 | * Swap the front and back buffers for the given buffer. No action is
|
|---|
| 279 | * taken if the buffer is not double buffered.
|
|---|
| 280 | */
|
|---|
| 281 | extern void XMesaSwapBuffers( XMesaBuffer b );
|
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 | /*
|
|---|
| 285 | * Copy a sub-region of the back buffer to the front buffer.
|
|---|
| 286 | *
|
|---|
| 287 | * New in Mesa 2.6
|
|---|
| 288 | */
|
|---|
| 289 | extern void XMesaCopySubBuffer( XMesaBuffer b,
|
|---|
| 290 | int x,
|
|---|
| 291 | int y,
|
|---|
| 292 | int width,
|
|---|
| 293 | int height );
|
|---|
| 294 |
|
|---|
| 295 |
|
|---|
| 296 | /*
|
|---|
| 297 | * Return a pointer to the the Pixmap or XImage being used as the back
|
|---|
| 298 | * color buffer of an XMesaBuffer. This function is a way to get "under
|
|---|
| 299 | * the hood" of X/Mesa so one can manipulate the back buffer directly.
|
|---|
| 300 | * Input: b - the XMesaBuffer
|
|---|
| 301 | * Output: pixmap - pointer to back buffer's Pixmap, or 0
|
|---|
| 302 | * ximage - pointer to back buffer's XImage, or NULL
|
|---|
| 303 | * Return: GL_TRUE = context is double buffered
|
|---|
| 304 | * GL_FALSE = context is single buffered
|
|---|
| 305 | */
|
|---|
| 306 | extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
|
|---|
| 307 | XMesaPixmap *pixmap,
|
|---|
| 308 | XMesaImage **ximage );
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 | /*
|
|---|
| 313 | * Return the depth buffer associated with an XMesaBuffer.
|
|---|
| 314 | * Input: b - the XMesa buffer handle
|
|---|
| 315 | * Output: width, height - size of buffer in pixels
|
|---|
| 316 | * bytesPerValue - bytes per depth value (2 or 4)
|
|---|
| 317 | * buffer - pointer to depth buffer values
|
|---|
| 318 | * Return: GL_TRUE or GL_FALSE to indicate success or failure.
|
|---|
| 319 | *
|
|---|
| 320 | * New in Mesa 2.4.
|
|---|
| 321 | */
|
|---|
| 322 | extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
|
|---|
| 323 | GLint *width,
|
|---|
| 324 | GLint *height,
|
|---|
| 325 | GLint *bytesPerValue,
|
|---|
| 326 | void **buffer );
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 | /*
|
|---|
| 331 | * Flush/sync a context
|
|---|
| 332 | */
|
|---|
| 333 | extern void XMesaFlush( XMesaContext c );
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 | /*
|
|---|
| 338 | * Get an X/Mesa-specific string.
|
|---|
| 339 | * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
|
|---|
| 340 | */
|
|---|
| 341 | extern const char *XMesaGetString( XMesaContext c, int name );
|
|---|
| 342 |
|
|---|
| 343 |
|
|---|
| 344 |
|
|---|
| 345 | /*
|
|---|
| 346 | * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
|
|---|
| 347 | * any memory used by that buffer.
|
|---|
| 348 | *
|
|---|
| 349 | * New in Mesa 2.3.
|
|---|
| 350 | */
|
|---|
| 351 | extern void XMesaGarbageCollect( void );
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 | /*
|
|---|
| 356 | * Return a dithered pixel value.
|
|---|
| 357 | * Input: c - XMesaContext
|
|---|
| 358 | * x, y - window coordinate
|
|---|
| 359 | * red, green, blue, alpha - color components in [0,1]
|
|---|
| 360 | * Return: pixel value
|
|---|
| 361 | *
|
|---|
| 362 | * New in Mesa 2.3.
|
|---|
| 363 | */
|
|---|
| 364 | extern unsigned long XMesaDitherColor( XMesaContext xmesa,
|
|---|
| 365 | GLint x,
|
|---|
| 366 | GLint y,
|
|---|
| 367 | GLfloat red,
|
|---|
| 368 | GLfloat green,
|
|---|
| 369 | GLfloat blue,
|
|---|
| 370 | GLfloat alpha );
|
|---|
| 371 |
|
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 | /*
|
|---|
| 375 | * 3Dfx Glide driver only!
|
|---|
| 376 | * Set 3Dfx/Glide full-screen or window rendering mode.
|
|---|
| 377 | * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
|
|---|
| 378 | * XMESA_FX_FULLSCREEN (full-screen rendering mode)
|
|---|
| 379 | * Return: GL_TRUE if success
|
|---|
| 380 | * GL_FALSE if invalid mode or if not using 3Dfx driver
|
|---|
| 381 | *
|
|---|
| 382 | * New in Mesa 2.6.
|
|---|
| 383 | */
|
|---|
| 384 | extern GLboolean XMesaSetFXmode( GLint mode );
|
|---|
| 385 |
|
|---|
| 386 |
|
|---|
| 387 |
|
|---|
| 388 | #ifdef __cplusplus
|
|---|
| 389 | }
|
|---|
| 390 | #endif
|
|---|
| 391 |
|
|---|
| 392 |
|
|---|
| 393 | #endif
|
|---|