1 /* $Id: xmesa.h,v 1.2 1999/11/24 18:36:14 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999 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.
30 * Revision 1.2 1999/11/24 18:36:14 brianp
31 * added XMesaMakeCurrent2(), XMesaGetCurrentReadBuffer(), bumped version to 3.3
33 * Revision 1.1.1.1 1999/08/19 00:55:40 jtg
36 * Revision 1.3 1999/02/24 22:43:27 jens
37 * Name changes to get XMesa to compile standalone inside XFree86
39 * Revision 1.2 1999/02/14 03:39:09 brianp
42 * Revision 1.1 1998/02/13 03:17:32 brianp
49 * Mesa/X11 interface. This header file serves as the documentation for
50 * the Mesa/X11 interface functions.
52 * Note: this interface isn't intended for user programs. It's primarily
53 * just for implementing the pseudo-GLX interface.
59 In addition to the usual X calls to select a visual, create a colormap
60 and create a window, you must do the following to use the X/Mesa interface:
62 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
64 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
67 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
70 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
71 to make the context the current one.
73 5. Make gl* calls to render your graphics.
75 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
77 7. Before the X window is destroyed, call XMesaDestroyBuffer().
79 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
81 See the demos/xdemo.c and xmesa1.c files for examples.
97 #include "xmesa_xf86.h"
100 #include <X11/Xutil.h>
106 #include <pragmas/xlib_pragmas.h>
107 extern struct Library
*XLibBase
;
111 #define XMESA_MAJOR_VERSION 3
112 #define XMESA_MINOR_VERSION 3
117 * Values passed to XMesaGetString:
119 #define XMESA_VERSION 1
120 #define XMESA_EXTENSIONS 2
124 * Values passed to XMesaSetFXmode:
126 #define XMESA_FX_WINDOW 1
127 #define XMESA_FX_FULLSCREEN 2
131 typedef struct xmesa_context
*XMesaContext
;
133 typedef struct xmesa_visual
*XMesaVisual
;
135 typedef struct xmesa_buffer
*XMesaBuffer
;
141 * Create a new X/Mesa visual.
142 * Input: display - X11 display
143 * visinfo - an XVisualInfo pointer
144 * rgb_flag - GL_TRUE = RGB mode,
145 * GL_FALSE = color index mode
146 * alpha_flag - alpha buffer requested?
147 * db_flag - GL_TRUE = double-buffered,
148 * GL_FALSE = single buffered
149 * stereo_flag - stereo visual?
150 * depth_size - requested bits/depth values, or zero
151 * stencil_size - requested bits/stencil values, or zero
152 * accum_size - requested bits/component values, or zero
153 * ximage_flag - GL_TRUE = use an XImage for back buffer,
154 * GL_FALSE = use an off-screen pixmap for back buffer
155 * Return; a new XMesaVisual or 0 if error.
157 extern XMesaVisual
XMesaCreateVisual( XMesaDisplay
*display
,
158 XMesaVisualInfo visinfo
,
160 GLboolean alpha_flag
,
162 GLboolean stereo_flag
,
163 GLboolean ximage_flag
,
170 * Destroy an XMesaVisual, but not the associated XVisualInfo.
172 extern void XMesaDestroyVisual( XMesaVisual v
);
177 * Create a new XMesaContext for rendering into an X11 window.
179 * Input: visual - an XMesaVisual
180 * share_list - another XMesaContext with which to share display
181 * lists or NULL if no sharing is wanted.
182 * Return: an XMesaContext or NULL if error.
184 extern XMesaContext
XMesaCreateContext( XMesaVisual v
,
185 XMesaContext share_list
);
189 * Destroy a rendering context as returned by XMesaCreateContext()
191 extern void XMesaDestroyContext( XMesaContext c
);
195 * Create an XMesaBuffer from an X window.
197 extern XMesaBuffer
XMesaCreateWindowBuffer( XMesaVisual v
,
202 * Create an XMesaBuffer from an X pixmap.
204 extern XMesaBuffer
XMesaCreatePixmapBuffer( XMesaVisual v
,
206 XMesaColormap cmap
);
210 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
212 extern void XMesaDestroyBuffer( XMesaBuffer b
);
216 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
220 extern XMesaBuffer
XMesaFindBuffer( XMesaDisplay
*dpy
,
226 * Bind a buffer to a context and make the context the current one.
228 extern GLboolean
XMesaMakeCurrent( XMesaContext c
,
233 * Bind two buffers (read and draw) to a context and make the
234 * context the current one.
237 extern GLboolean
XMesaMakeCurrent2( XMesaContext c
,
238 XMesaBuffer drawBuffer
,
239 XMesaBuffer readBuffer
);
243 * Return a handle to the current context.
245 extern XMesaContext
XMesaGetCurrentContext( void );
249 * Return handle to the current (draw) buffer.
251 extern XMesaBuffer
XMesaGetCurrentBuffer( void );
255 * Return handle to the current read buffer.
258 extern XMesaBuffer
XMesaGetCurrentReadBuffer( void );
262 * Swap the front and back buffers for the given buffer. No action is
263 * taken if the buffer is not double buffered.
265 extern void XMesaSwapBuffers( XMesaBuffer b
);
269 * Copy a sub-region of the back buffer to the front buffer.
273 extern void XMesaCopySubBuffer( XMesaBuffer b
,
281 * Return a pointer to the the Pixmap or XImage being used as the back
282 * color buffer of an XMesaBuffer. This function is a way to get "under
283 * the hood" of X/Mesa so one can manipulate the back buffer directly.
284 * Input: b - the XMesaBuffer
285 * Output: pixmap - pointer to back buffer's Pixmap, or 0
286 * ximage - pointer to back buffer's XImage, or NULL
287 * Return: GL_TRUE = context is double buffered
288 * GL_FALSE = context is single buffered
290 extern GLboolean
XMesaGetBackBuffer( XMesaBuffer b
,
292 XMesaImage
**ximage
);
297 * Return the depth buffer associated with an XMesaBuffer.
298 * Input: b - the XMesa buffer handle
299 * Output: width, height - size of buffer in pixels
300 * bytesPerValue - bytes per depth value (2 or 4)
301 * buffer - pointer to depth buffer values
302 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
306 extern GLboolean
XMesaGetDepthBuffer( XMesaBuffer b
,
309 GLint
*bytesPerValue
,
315 * Flush/sync a context
317 extern void XMesaFlush( XMesaContext c
);
322 * Get an X/Mesa-specific string.
323 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
325 extern const char *XMesaGetString( XMesaContext c
, int name
);
330 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
331 * any memory used by that buffer.
335 extern void XMesaGarbageCollect( void );
340 * Return a dithered pixel value.
341 * Input: c - XMesaContext
342 * x, y - window coordinate
343 * red, green, blue, alpha - color components in [0,1]
344 * Return: pixel value
348 extern unsigned long XMesaDitherColor( XMesaContext xmesa
,
359 * 3Dfx Glide driver only!
360 * Set 3Dfx/Glide full-screen or window rendering mode.
361 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
362 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
363 * Return: GL_TRUE if success
364 * GL_FALSE if invalid mode or if not using 3Dfx driver
368 extern GLboolean
XMesaSetFXmode( GLint mode
);