bumped version to 3.3
[mesa.git] / include / GL / xmesa.h
1 /* $Id: xmesa.h,v 1.2 1999/11/24 18:36:14 brianp Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.3
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.2 1999/11/24 18:36:14 brianp
31 * added XMesaMakeCurrent2(), XMesaGetCurrentReadBuffer(), bumped version to 3.3
32 *
33 * Revision 1.1.1.1 1999/08/19 00:55:40 jtg
34 * Imported sources
35 *
36 * Revision 1.3 1999/02/24 22:43:27 jens
37 * Name changes to get XMesa to compile standalone inside XFree86
38 *
39 * Revision 1.2 1999/02/14 03:39:09 brianp
40 * new copyright
41 *
42 * Revision 1.1 1998/02/13 03:17:32 brianp
43 * Initial revision
44 *
45 */
46
47
48 /*
49 * Mesa/X11 interface. This header file serves as the documentation for
50 * the Mesa/X11 interface functions.
51 *
52 * Note: this interface isn't intended for user programs. It's primarily
53 * just for implementing the pseudo-GLX interface.
54 */
55
56
57 /* Sample Usage:
58
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:
61
62 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
63
64 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
65 the XMesaVisual.
66
67 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
68 and XMesaVisual.
69
70 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
71 to make the context the current one.
72
73 5. Make gl* calls to render your graphics.
74
75 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
76
77 7. Before the X window is destroyed, call XMesaDestroyBuffer().
78
79 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
80
81 See the demos/xdemo.c and xmesa1.c files for examples.
82 */
83
84
85
86
87 #ifndef XMESA_H
88 #define XMESA_H
89
90
91 #ifdef __cplusplus
92 extern "C" {
93 #endif
94
95
96 #ifdef XFree86Server
97 #include "xmesa_xf86.h"
98 #else
99 #include <X11/Xlib.h>
100 #include <X11/Xutil.h>
101 #include "xmesa_x.h"
102 #endif
103 #include "GL/gl.h"
104
105 #ifdef AMIWIN
106 #include <pragmas/xlib_pragmas.h>
107 extern struct Library *XLibBase;
108 #endif
109
110
111 #define XMESA_MAJOR_VERSION 3
112 #define XMESA_MINOR_VERSION 3
113
114
115
116 /*
117 * Values passed to XMesaGetString:
118 */
119 #define XMESA_VERSION 1
120 #define XMESA_EXTENSIONS 2
121
122
123 /*
124 * Values passed to XMesaSetFXmode:
125 */
126 #define XMESA_FX_WINDOW 1
127 #define XMESA_FX_FULLSCREEN 2
128
129
130
131 typedef struct xmesa_context *XMesaContext;
132
133 typedef struct xmesa_visual *XMesaVisual;
134
135 typedef struct xmesa_buffer *XMesaBuffer;
136
137
138
139
140 /*
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.
156 */
157 extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
158 XMesaVisualInfo visinfo,
159 GLboolean rgb_flag,
160 GLboolean alpha_flag,
161 GLboolean db_flag,
162 GLboolean stereo_flag,
163 GLboolean ximage_flag,
164 GLint depth_size,
165 GLint stencil_size,
166 GLint accum_size,
167 GLint level );
168
169 /*
170 * Destroy an XMesaVisual, but not the associated XVisualInfo.
171 */
172 extern void XMesaDestroyVisual( XMesaVisual v );
173
174
175
176 /*
177 * Create a new XMesaContext for rendering into an X11 window.
178 *
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.
183 */
184 extern XMesaContext XMesaCreateContext( XMesaVisual v,
185 XMesaContext share_list );
186
187
188 /*
189 * Destroy a rendering context as returned by XMesaCreateContext()
190 */
191 extern void XMesaDestroyContext( XMesaContext c );
192
193
194 /*
195 * Create an XMesaBuffer from an X window.
196 */
197 extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
198 XMesaWindow w );
199
200
201 /*
202 * Create an XMesaBuffer from an X pixmap.
203 */
204 extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
205 XMesaPixmap p,
206 XMesaColormap cmap );
207
208
209 /*
210 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
211 */
212 extern void XMesaDestroyBuffer( XMesaBuffer b );
213
214
215 /*
216 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
217 *
218 * New in Mesa 2.3.
219 */
220 extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
221 XMesaDrawable d );
222
223
224
225 /*
226 * Bind a buffer to a context and make the context the current one.
227 */
228 extern GLboolean XMesaMakeCurrent( XMesaContext c,
229 XMesaBuffer b );
230
231
232 /*
233 * Bind two buffers (read and draw) to a context and make the
234 * context the current one.
235 * New in Mesa 3.3
236 */
237 extern GLboolean XMesaMakeCurrent2( XMesaContext c,
238 XMesaBuffer drawBuffer,
239 XMesaBuffer readBuffer );
240
241
242 /*
243 * Return a handle to the current context.
244 */
245 extern XMesaContext XMesaGetCurrentContext( void );
246
247
248 /*
249 * Return handle to the current (draw) buffer.
250 */
251 extern XMesaBuffer XMesaGetCurrentBuffer( void );
252
253
254 /*
255 * Return handle to the current read buffer.
256 * New in Mesa 3.3
257 */
258 extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
259
260
261 /*
262 * Swap the front and back buffers for the given buffer. No action is
263 * taken if the buffer is not double buffered.
264 */
265 extern void XMesaSwapBuffers( XMesaBuffer b );
266
267
268 /*
269 * Copy a sub-region of the back buffer to the front buffer.
270 *
271 * New in Mesa 2.6
272 */
273 extern void XMesaCopySubBuffer( XMesaBuffer b,
274 int x,
275 int y,
276 int width,
277 int height );
278
279
280 /*
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
289 */
290 extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
291 XMesaPixmap *pixmap,
292 XMesaImage **ximage );
293
294
295
296 /*
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.
303 *
304 * New in Mesa 2.4.
305 */
306 extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
307 GLint *width,
308 GLint *height,
309 GLint *bytesPerValue,
310 void **buffer );
311
312
313
314 /*
315 * Flush/sync a context
316 */
317 extern void XMesaFlush( XMesaContext c );
318
319
320
321 /*
322 * Get an X/Mesa-specific string.
323 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
324 */
325 extern const char *XMesaGetString( XMesaContext c, int name );
326
327
328
329 /*
330 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
331 * any memory used by that buffer.
332 *
333 * New in Mesa 2.3.
334 */
335 extern void XMesaGarbageCollect( void );
336
337
338
339 /*
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
345 *
346 * New in Mesa 2.3.
347 */
348 extern unsigned long XMesaDitherColor( XMesaContext xmesa,
349 GLint x,
350 GLint y,
351 GLfloat red,
352 GLfloat green,
353 GLfloat blue,
354 GLfloat alpha );
355
356
357
358 /*
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
365 *
366 * New in Mesa 2.6.
367 */
368 extern GLboolean XMesaSetFXmode( GLint mode );
369
370
371
372 #ifdef __cplusplus
373 }
374 #endif
375
376
377 #endif