1 /* $Id: xmesa.h,v 1.1.1.1 2002/02/01 06:35:43 tacyas Exp $ */
4 * Mesa 3-D graphics library
6 * Copyright (C) 1995-1998 Brian Paul
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the Free
20 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 * Revision 1.1.1.1 2002/02/01 06:35:43 tacyas
27 * Initail Import Into CVS
29 * Revision 1.1 1998/02/13 03:17:32 brianp
36 * Mesa/X11 interface. This header file serves as the documentation for
37 * the Mesa/X11 interface functions.
39 * Note: this interface isn't intended for user programs. It's primarily
40 * just for implementing the pseudo-GLX interface.
46 In addition to the usual X calls to select a visual, create a colormap
47 and create a window, you must do the following to use the X/Mesa interface:
49 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
51 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
54 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
57 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
58 to make the context the current one.
60 5. Make gl* calls to render your graphics.
62 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
64 7. Before the X window is destroyed, call XMesaDestroyBuffer().
66 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
68 See the demos/xdemo.c and xmesa1.c files for examples.
84 #include <X11/Xutil.h>
88 #include <pragmas/xlib_pragmas.h>
89 extern struct Library *XLibBase;
93 #define XMESA_MAJOR_VERSION 3
94 #define XMESA_MINOR_VERSION 0
99 * Values passed to XMesaGetString:
101 #define XMESA_VERSION 1
102 #define XMESA_EXTENSIONS 2
106 * Values passed to XMesaSetFXmode:
108 #define XMESA_FX_WINDOW 1
109 #define XMESA_FX_FULLSCREEN 2
113 typedef struct xmesa_context *XMesaContext;
115 typedef struct xmesa_visual *XMesaVisual;
117 typedef struct xmesa_buffer *XMesaBuffer;
123 * Create a new X/Mesa visual.
124 * Input: display - X11 display
125 * visinfo - an XVisualInfo pointer
126 * rgb_flag - GL_TRUE = RGB mode,
127 * GL_FALSE = color index mode
128 * alpha_flag - alpha buffer requested?
129 * db_flag - GL_TRUE = double-buffered,
130 * GL_FALSE = single buffered
131 * stereo_flag - stereo visual?
132 * depth_size - requested bits/depth values, or zero
133 * stencil_size - requested bits/stencil values, or zero
134 * accum_size - requested bits/component values, or zero
135 * ximage_flag - GL_TRUE = use an XImage for back buffer,
136 * GL_FALSE = use an off-screen pixmap for back buffer
137 * Return; a new XMesaVisual or 0 if error.
139 extern XMesaVisual XMesaCreateVisual( Display *display,
140 XVisualInfo *visinfo,
142 GLboolean alpha_flag,
144 GLboolean stereo_flag,
145 GLboolean ximage_flag,
152 * Destroy an XMesaVisual, but not the associated XVisualInfo.
154 extern void XMesaDestroyVisual( XMesaVisual v );
159 * Create a new XMesaContext for rendering into an X11 window.
161 * Input: visual - an XMesaVisual
162 * share_list - another XMesaContext with which to share display
163 * lists or NULL if no sharing is wanted.
164 * Return: an XMesaContext or NULL if error.
166 extern XMesaContext XMesaCreateContext( XMesaVisual visual,
167 XMesaContext share_list );
171 * Destroy a rendering context as returned by XMesaCreateContext()
173 extern void XMesaDestroyContext( XMesaContext c );
177 * Create an XMesaBuffer from an X window.
179 extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, Window w );
183 * Create an XMesaBuffer from an X pixmap.
185 extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, Pixmap p,
190 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
192 extern void XMesaDestroyBuffer( XMesaBuffer b );
196 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
200 extern XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d );
205 * Bind a buffer to a context and make the context the current one.
207 extern GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b );
211 * Return a handle to the current context.
213 extern XMesaContext XMesaGetCurrentContext( void );
217 * Return handle to the current buffer.
219 extern XMesaBuffer XMesaGetCurrentBuffer( void );
223 * Swap the front and back buffers for the given buffer. No action is
224 * taken if the buffer is not double buffered.
226 extern void XMesaSwapBuffers( XMesaBuffer b );
230 * Copy a sub-region of the back buffer to the front buffer.
234 extern void XMesaCopySubBuffer( XMesaBuffer b,
235 int x, int y, int width, int height );
239 * Return a pointer to the the Pixmap or XImage being used as the back
240 * color buffer of an XMesaBuffer. This function is a way to get "under
241 * the hood" of X/Mesa so one can manipulate the back buffer directly.
242 * Input: b - the XMesaBuffer
243 * Output: pixmap - pointer to back buffer's Pixmap, or 0
244 * ximage - pointer to back buffer's XImage, or NULL
245 * Return: GL_TRUE = context is double buffered
246 * GL_FALSE = context is single buffered
248 extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
249 Pixmap *pixmap, XImage **ximage );
254 * Return the depth buffer associated with an XMesaBuffer.
255 * Input: b - the XMesa buffer handle
256 * Output: width, height - size of buffer in pixels
257 * bytesPerValue - bytes per depth value (2 or 4)
258 * buffer - pointer to depth buffer values
259 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
263 extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
264 GLint *width, GLint *height,
265 GLint *bytesPerValue, void **buffer );
270 * Flush/sync a context
272 extern void XMesaFlush( XMesaContext c );
277 * Get an X/Mesa-specific string.
278 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
280 extern const char *XMesaGetString( XMesaContext c, int name );
285 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
286 * any memory used by that buffer.
290 extern void XMesaGarbageCollect( void );
295 * Return a dithered pixel value.
296 * Input: c - XMesaContext
297 * x, y - window coordinate
298 * red, green, blue, alpha - color components in [0,1]
299 * Return: pixel value
303 extern unsigned long XMesaDitherColor( XMesaContext c, GLint x, GLint y,
304 GLfloat red, GLfloat green,
305 GLfloat blue, GLfloat alpha );
310 * 3Dfx Glide driver only!
311 * Set 3Dfx/Glide full-screen or window rendering mode.
312 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
313 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
314 * Return: GL_TRUE if success
315 * GL_FALSE if invalid mode or if not using 3Dfx driver
319 extern GLboolean XMesaSetFXmode( GLint mode );