1 /* $Id: xmesa.h,v 1.10 2001/01/24 00:07:01 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
29 * Mesa/X11 interface. This header file serves as the documentation for
30 * the Mesa/X11 interface functions.
32 * Note: this interface isn't intended for user programs. It's primarily
33 * just for implementing the pseudo-GLX interface.
39 In addition to the usual X calls to select a visual, create a colormap
40 and create a window, you must do the following to use the X/Mesa interface:
42 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
44 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
47 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
50 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
51 to make the context the current one.
53 5. Make gl* calls to render your graphics.
55 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
57 7. Before the X window is destroyed, call XMesaDestroyBuffer().
59 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
70 #include <GL/vms_x_fix.h>
78 #include "xmesa_xf86.h"
81 #include <X11/Xutil.h>
87 #include <pragmas/xlib_pragmas.h>
88 extern struct Library
*XLibBase
;
92 #define XMESA_MAJOR_VERSION 3
93 #define XMESA_MINOR_VERSION 3
98 * Values passed to XMesaGetString:
100 #define XMESA_VERSION 1
101 #define XMESA_EXTENSIONS 2
105 * Values passed to XMesaSetFXmode:
107 #define XMESA_FX_WINDOW 1
108 #define XMESA_FX_FULLSCREEN 2
112 typedef struct xmesa_context
*XMesaContext
;
114 typedef struct xmesa_visual
*XMesaVisual
;
116 typedef struct xmesa_buffer
*XMesaBuffer
;
121 * Create a new X/Mesa visual.
122 * Input: display - X11 display
123 * visinfo - an XVisualInfo pointer
124 * rgb_flag - GL_TRUE = RGB mode,
125 * GL_FALSE = color index mode
126 * alpha_flag - alpha buffer requested?
127 * db_flag - GL_TRUE = double-buffered,
128 * GL_FALSE = single buffered
129 * stereo_flag - stereo visual?
130 * ximage_flag - GL_TRUE = use an XImage for back buffer,
131 * GL_FALSE = use an off-screen pixmap for back buffer
132 * depth_size - requested bits/depth values, or zero
133 * stencil_size - requested bits/stencil values, or zero
134 * accum_red_size - requested bits/red accum values, or zero
135 * accum_green_size - requested bits/green accum values, or zero
136 * accum_blue_size - requested bits/blue accum values, or zero
137 * accum_alpha_size - requested bits/alpha accum values, or zero
138 * num_samples - number of samples/pixel if multisampling, or zero
139 * level - visual level, usually 0
140 * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
141 * Return; a new XMesaVisual or 0 if error.
143 extern XMesaVisual
XMesaCreateVisual( XMesaDisplay
*display
,
144 XMesaVisualInfo visinfo
,
146 GLboolean alpha_flag
,
148 GLboolean stereo_flag
,
149 GLboolean ximage_flag
,
152 GLint accum_red_size
,
153 GLint accum_green_size
,
154 GLint accum_blue_size
,
155 GLint accum_alpha_size
,
158 GLint visualCaveat
);
161 * Destroy an XMesaVisual, but not the associated XVisualInfo.
163 extern void XMesaDestroyVisual( XMesaVisual v
);
168 * Create a new XMesaContext for rendering into an X11 window.
170 * Input: visual - an XMesaVisual
171 * share_list - another XMesaContext with which to share display
172 * lists or NULL if no sharing is wanted.
173 * Return: an XMesaContext or NULL if error.
175 extern XMesaContext
XMesaCreateContext( XMesaVisual v
,
176 XMesaContext share_list
);
180 * Destroy a rendering context as returned by XMesaCreateContext()
182 extern void XMesaDestroyContext( XMesaContext c
);
186 * Create an XMesaBuffer from an X window.
188 extern XMesaBuffer
XMesaCreateWindowBuffer( XMesaVisual v
, XMesaWindow w
);
192 * Create an XMesaBuffer from an X pixmap.
194 extern XMesaBuffer
XMesaCreatePixmapBuffer( XMesaVisual v
,
196 XMesaColormap cmap
);
200 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
202 extern void XMesaDestroyBuffer( XMesaBuffer b
);
206 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
210 extern XMesaBuffer
XMesaFindBuffer( XMesaDisplay
*dpy
,
216 * Bind a buffer to a context and make the context the current one.
218 extern GLboolean
XMesaMakeCurrent( XMesaContext c
,
223 * Bind two buffers (read and draw) to a context and make the
224 * context the current one.
227 extern GLboolean
XMesaMakeCurrent2( XMesaContext c
,
228 XMesaBuffer drawBuffer
,
229 XMesaBuffer readBuffer
);
233 * Unbind the current context from its buffer.
235 extern GLboolean
XMesaUnbindContext( XMesaContext c
);
239 * Return a handle to the current context.
241 extern XMesaContext
XMesaGetCurrentContext( void );
245 * Return handle to the current (draw) buffer.
247 extern XMesaBuffer
XMesaGetCurrentBuffer( void );
251 * Return handle to the current read buffer.
254 extern XMesaBuffer
XMesaGetCurrentReadBuffer( void );
258 * Swap the front and back buffers for the given buffer. No action is
259 * taken if the buffer is not double buffered.
261 extern void XMesaSwapBuffers( XMesaBuffer b
);
265 * Copy a sub-region of the back buffer to the front buffer.
269 extern void XMesaCopySubBuffer( XMesaBuffer b
,
277 * Return a pointer to the the Pixmap or XImage being used as the back
278 * color buffer of an XMesaBuffer. This function is a way to get "under
279 * the hood" of X/Mesa so one can manipulate the back buffer directly.
280 * Input: b - the XMesaBuffer
281 * Output: pixmap - pointer to back buffer's Pixmap, or 0
282 * ximage - pointer to back buffer's XImage, or NULL
283 * Return: GL_TRUE = context is double buffered
284 * GL_FALSE = context is single buffered
286 extern GLboolean
XMesaGetBackBuffer( XMesaBuffer b
,
288 XMesaImage
**ximage
);
293 * Return the depth buffer associated with an XMesaBuffer.
294 * Input: b - the XMesa buffer handle
295 * Output: width, height - size of buffer in pixels
296 * bytesPerValue - bytes per depth value (2 or 4)
297 * buffer - pointer to depth buffer values
298 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
302 extern GLboolean
XMesaGetDepthBuffer( XMesaBuffer b
,
305 GLint
*bytesPerValue
,
311 * Flush/sync a context
313 extern void XMesaFlush( XMesaContext c
);
318 * Get an X/Mesa-specific string.
319 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
321 extern const char *XMesaGetString( XMesaContext c
, int name
);
326 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
327 * any memory used by that buffer.
331 extern void XMesaGarbageCollect( void );
336 * Return a dithered pixel value.
337 * Input: c - XMesaContext
338 * x, y - window coordinate
339 * red, green, blue, alpha - color components in [0,1]
340 * Return: pixel value
344 extern unsigned long XMesaDitherColor( XMesaContext xmesa
,
355 * 3Dfx Glide driver only!
356 * Set 3Dfx/Glide full-screen or window rendering mode.
357 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
358 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
359 * Return: GL_TRUE if success
360 * GL_FALSE if invalid mode or if not using 3Dfx driver
364 extern GLboolean
XMesaSetFXmode( GLint mode
);