2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Mesa/X11 interface. This header file serves as the documentation for
28 * the Mesa/X11 interface functions.
30 * Note: this interface isn't intended for user programs. It's primarily
31 * just for implementing the pseudo-GLX interface.
37 In addition to the usual X calls to select a visual, create a colormap
38 and create a window, you must do the following to use the X/Mesa interface:
40 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
42 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
45 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
48 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
49 to make the context the current one.
51 5. Make gl* calls to render your graphics.
53 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
55 7. Before the X window is destroyed, call XMesaDestroyBuffer().
57 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
68 #include <GL/vms_x_fix.h>
76 #include "xmesa_xf86.h"
79 #include <X11/Xutil.h>
85 #include <pragmas/xlib_pragmas.h>
86 extern struct Library
*XLibBase
;
90 #define XMESA_MAJOR_VERSION 6
91 #define XMESA_MINOR_VERSION 3
96 * Values passed to XMesaGetString:
98 #define XMESA_VERSION 1
99 #define XMESA_EXTENSIONS 2
103 * Values passed to XMesaSetFXmode:
105 #define XMESA_FX_WINDOW 1
106 #define XMESA_FX_FULLSCREEN 2
110 typedef struct xmesa_context
*XMesaContext
;
112 typedef struct xmesa_visual
*XMesaVisual
;
114 typedef struct xmesa_buffer
*XMesaBuffer
;
119 * Create a new X/Mesa visual.
120 * Input: display - X11 display
121 * visinfo - an XVisualInfo pointer
122 * rgb_flag - GL_TRUE = RGB mode,
123 * GL_FALSE = color index mode
124 * alpha_flag - alpha buffer requested?
125 * db_flag - GL_TRUE = double-buffered,
126 * GL_FALSE = single buffered
127 * stereo_flag - stereo visual?
128 * ximage_flag - GL_TRUE = use an XImage for back buffer,
129 * GL_FALSE = use an off-screen pixmap for back buffer
130 * depth_size - requested bits/depth values, or zero
131 * stencil_size - requested bits/stencil values, or zero
132 * accum_red_size - requested bits/red accum values, or zero
133 * accum_green_size - requested bits/green accum values, or zero
134 * accum_blue_size - requested bits/blue accum values, or zero
135 * accum_alpha_size - requested bits/alpha accum values, or zero
136 * num_samples - number of samples/pixel if multisampling, or zero
137 * level - visual level, usually 0
138 * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
139 * Return; a new XMesaVisual or 0 if error.
141 extern XMesaVisual
XMesaCreateVisual( XMesaDisplay
*display
,
142 XMesaVisualInfo visinfo
,
144 GLboolean alpha_flag
,
146 GLboolean stereo_flag
,
147 GLboolean ximage_flag
,
150 GLint accum_red_size
,
151 GLint accum_green_size
,
152 GLint accum_blue_size
,
153 GLint accum_alpha_size
,
156 GLint visualCaveat
);
159 * Destroy an XMesaVisual, but not the associated XVisualInfo.
161 extern void XMesaDestroyVisual( XMesaVisual v
);
166 * Create a new XMesaContext for rendering into an X11 window.
168 * Input: visual - an XMesaVisual
169 * share_list - another XMesaContext with which to share display
170 * lists or NULL if no sharing is wanted.
171 * Return: an XMesaContext or NULL if error.
173 extern XMesaContext
XMesaCreateContext( XMesaVisual v
,
174 XMesaContext share_list
);
178 * Destroy a rendering context as returned by XMesaCreateContext()
180 extern void XMesaDestroyContext( XMesaContext c
);
184 * Create an XMesaBuffer from an X window.
186 extern XMesaBuffer
XMesaCreateWindowBuffer( XMesaVisual v
, XMesaWindow w
);
190 * Create an XMesaBuffer from an X pixmap.
192 extern XMesaBuffer
XMesaCreatePixmapBuffer( XMesaVisual v
,
194 XMesaColormap cmap
);
198 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
200 extern void XMesaDestroyBuffer( XMesaBuffer b
);
204 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
208 extern XMesaBuffer
XMesaFindBuffer( XMesaDisplay
*dpy
,
214 * Bind a buffer to a context and make the context the current one.
216 extern GLboolean
XMesaMakeCurrent( XMesaContext c
,
221 * Bind two buffers (read and draw) to a context and make the
222 * context the current one.
225 extern GLboolean
XMesaMakeCurrent2( XMesaContext c
,
226 XMesaBuffer drawBuffer
,
227 XMesaBuffer readBuffer
);
231 * Unbind the current context from its buffer.
233 extern GLboolean
XMesaUnbindContext( XMesaContext c
);
237 * Return a handle to the current context.
239 extern XMesaContext
XMesaGetCurrentContext( void );
243 * Return handle to the current (draw) buffer.
245 extern XMesaBuffer
XMesaGetCurrentBuffer( void );
249 * Return handle to the current read buffer.
252 extern XMesaBuffer
XMesaGetCurrentReadBuffer( void );
256 * Swap the front and back buffers for the given buffer. No action is
257 * taken if the buffer is not double buffered.
259 extern void XMesaSwapBuffers( XMesaBuffer b
);
263 * Copy a sub-region of the back buffer to the front buffer.
267 extern void XMesaCopySubBuffer( XMesaBuffer b
,
275 * Return a pointer to the the Pixmap or XImage being used as the back
276 * color buffer of an XMesaBuffer. This function is a way to get "under
277 * the hood" of X/Mesa so one can manipulate the back buffer directly.
278 * Input: b - the XMesaBuffer
279 * Output: pixmap - pointer to back buffer's Pixmap, or 0
280 * ximage - pointer to back buffer's XImage, or NULL
281 * Return: GL_TRUE = context is double buffered
282 * GL_FALSE = context is single buffered
284 extern GLboolean
XMesaGetBackBuffer( XMesaBuffer b
,
286 XMesaImage
**ximage
);
291 * Return the depth buffer associated with an XMesaBuffer.
292 * Input: b - the XMesa buffer handle
293 * Output: width, height - size of buffer in pixels
294 * bytesPerValue - bytes per depth value (2 or 4)
295 * buffer - pointer to depth buffer values
296 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
300 extern GLboolean
XMesaGetDepthBuffer( XMesaBuffer b
,
303 GLint
*bytesPerValue
,
309 * Flush/sync a context
311 extern void XMesaFlush( XMesaContext c
);
316 * Get an X/Mesa-specific string.
317 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
319 extern const char *XMesaGetString( XMesaContext c
, int name
);
324 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
325 * any memory used by that buffer.
329 extern void XMesaGarbageCollect( void );
334 * Return a dithered pixel value.
335 * Input: c - XMesaContext
336 * x, y - window coordinate
337 * red, green, blue, alpha - color components in [0,1]
338 * Return: pixel value
342 extern unsigned long XMesaDitherColor( XMesaContext xmesa
,
353 * 3Dfx Glide driver only!
354 * Set 3Dfx/Glide full-screen or window rendering mode.
355 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
356 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
357 * Return: GL_TRUE if success
358 * GL_FALSE if invalid mode or if not using 3Dfx driver
362 extern GLboolean
XMesaSetFXmode( GLint mode
);
367 * Reallocate the back/depth/stencil/accum/etc/ buffers associated with
368 * buffer <b> if its size has changed.
372 extern void XMesaResizeBuffers( XMesaBuffer b
);
380 extern XMesaBuffer
XMesaCreatePBuffer(XMesaVisual v
, XMesaColormap cmap
,
381 unsigned int width
, unsigned int height
);