blob: 273b83508c7100077c4559e27c15f1111578ec31 [file] [log] [blame]
Jouk Jansenb5b5c522000-08-22 13:31:00 +00001/* $Id: xmesa.h,v 1.9 2000/08/22 13:31:01 joukj Exp $ */
jtgafb833d1999-08-19 00:55:39 +00002
3/*
4 * Mesa 3-D graphics library
Brian Paul2257a121999-11-24 18:36:14 +00005 * Version: 3.3
jtgafb833d1999-08-19 00:55:39 +00006 *
Brian Paul4049cd32000-01-13 17:40:12 +00007 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
jtgafb833d1999-08-19 00:55:39 +00008 *
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/*
jtgafb833d1999-08-19 00:55:39 +000029 * Mesa/X11 interface. This header file serves as the documentation for
30 * the Mesa/X11 interface functions.
31 *
32 * Note: this interface isn't intended for user programs. It's primarily
33 * just for implementing the pseudo-GLX interface.
34 */
35
36
37/* Sample Usage:
38
39In addition to the usual X calls to select a visual, create a colormap
40and create a window, you must do the following to use the X/Mesa interface:
41
421. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
43
442. Call XMesaCreateContext() to create an X/Mesa rendering context, given
45 the XMesaVisual.
46
473. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
48 and XMesaVisual.
49
504. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
51 to make the context the current one.
52
535. Make gl* calls to render your graphics.
54
556. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
56
577. Before the X window is destroyed, call XMesaDestroyBuffer().
58
598. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
60
61See the demos/xdemo.c and xmesa1.c files for examples.
62*/
63
64
65
66
67#ifndef XMESA_H
68#define XMESA_H
69
Jouk Jansenb5b5c522000-08-22 13:31:00 +000070#ifdef __VMS
71#include <GL/vms_x_fix.h>
72#endif
jtgafb833d1999-08-19 00:55:39 +000073
74#ifdef __cplusplus
75extern "C" {
76#endif
77
jtgafb833d1999-08-19 00:55:39 +000078#ifdef XFree86Server
79#include "xmesa_xf86.h"
80#else
81#include <X11/Xlib.h>
82#include <X11/Xutil.h>
83#include "xmesa_x.h"
84#endif
85#include "GL/gl.h"
86
87#ifdef AMIWIN
88#include <pragmas/xlib_pragmas.h>
89extern struct Library *XLibBase;
90#endif
91
92
93#define XMESA_MAJOR_VERSION 3
Brian Paul2257a121999-11-24 18:36:14 +000094#define XMESA_MINOR_VERSION 3
jtgafb833d1999-08-19 00:55:39 +000095
96
97
98/*
99 * Values passed to XMesaGetString:
100 */
101#define XMESA_VERSION 1
102#define XMESA_EXTENSIONS 2
103
104
105/*
106 * Values passed to XMesaSetFXmode:
107 */
108#define XMESA_FX_WINDOW 1
109#define XMESA_FX_FULLSCREEN 2
110
111
112
113typedef struct xmesa_context *XMesaContext;
114
115typedef struct xmesa_visual *XMesaVisual;
116
117typedef struct xmesa_buffer *XMesaBuffer;
118
jtgafb833d1999-08-19 00:55:39 +0000119
120
121/*
122 * Create a new X/Mesa visual.
123 * Input: display - X11 display
124 * visinfo - an XVisualInfo pointer
125 * rgb_flag - GL_TRUE = RGB mode,
126 * GL_FALSE = color index mode
127 * alpha_flag - alpha buffer requested?
128 * db_flag - GL_TRUE = double-buffered,
129 * GL_FALSE = single buffered
130 * stereo_flag - stereo visual?
jtgafb833d1999-08-19 00:55:39 +0000131 * ximage_flag - GL_TRUE = use an XImage for back buffer,
132 * GL_FALSE = use an off-screen pixmap for back buffer
Brian Paulc8735e82000-04-05 22:09:58 +0000133 * depth_size - requested bits/depth values, or zero
134 * stencil_size - requested bits/stencil values, or zero
135 * accum_red_size - requested bits/red accum values, or zero
136 * accum_green_size - requested bits/green accum values, or zero
137 * accum_blue_size - requested bits/blue accum values, or zero
138 * accum_alpha_size - requested bits/alpha accum values, or zero
139 * num_samples - number of samples/pixel if multisampling, or zero
140 * level - visual level, usually 0
141 * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT
jtgafb833d1999-08-19 00:55:39 +0000142 * Return; a new XMesaVisual or 0 if error.
143 */
144extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
Brian Paulc8735e82000-04-05 22:09:58 +0000145 XMesaVisualInfo visinfo,
146 GLboolean rgb_flag,
147 GLboolean alpha_flag,
148 GLboolean db_flag,
149 GLboolean stereo_flag,
150 GLboolean ximage_flag,
151 GLint depth_size,
152 GLint stencil_size,
153 GLint accum_red_size,
154 GLint accum_green_size,
155 GLint accum_blue_size,
156 GLint accum_alpha_size,
157 GLint num_samples,
158 GLint level,
159 GLint visualCaveat );
Brian Paula5724062000-03-31 01:04:07 +0000160
jtgafb833d1999-08-19 00:55:39 +0000161/*
162 * Destroy an XMesaVisual, but not the associated XVisualInfo.
163 */
164extern void XMesaDestroyVisual( XMesaVisual v );
165
166
167
168/*
169 * Create a new XMesaContext for rendering into an X11 window.
170 *
171 * Input: visual - an XMesaVisual
172 * share_list - another XMesaContext with which to share display
173 * lists or NULL if no sharing is wanted.
174 * Return: an XMesaContext or NULL if error.
175 */
176extern XMesaContext XMesaCreateContext( XMesaVisual v,
Brian Paulede979f2000-05-02 02:30:01 +0000177 XMesaContext share_list );
jtgafb833d1999-08-19 00:55:39 +0000178
179
180/*
181 * Destroy a rendering context as returned by XMesaCreateContext()
182 */
183extern void XMesaDestroyContext( XMesaContext c );
184
185
186/*
187 * Create an XMesaBuffer from an X window.
188 */
Brian Paulede979f2000-05-02 02:30:01 +0000189extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
jtgafb833d1999-08-19 00:55:39 +0000190
191
192/*
193 * Create an XMesaBuffer from an X pixmap.
194 */
195extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
196 XMesaPixmap p,
Brian Paulede979f2000-05-02 02:30:01 +0000197 XMesaColormap cmap );
jtgafb833d1999-08-19 00:55:39 +0000198
199
200/*
201 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
202 */
203extern void XMesaDestroyBuffer( XMesaBuffer b );
204
205
206/*
207 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
208 *
209 * New in Mesa 2.3.
210 */
211extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
212 XMesaDrawable d );
213
214
215
216/*
217 * Bind a buffer to a context and make the context the current one.
218 */
219extern GLboolean XMesaMakeCurrent( XMesaContext c,
220 XMesaBuffer b );
221
222
223/*
Brian Paul2257a121999-11-24 18:36:14 +0000224 * Bind two buffers (read and draw) to a context and make the
225 * context the current one.
226 * New in Mesa 3.3
227 */
228extern GLboolean XMesaMakeCurrent2( XMesaContext c,
229 XMesaBuffer drawBuffer,
230 XMesaBuffer readBuffer );
231
232
233/*
Brian Paulf9db0032000-02-25 20:30:23 +0000234 * Unbind the current context from its buffer.
235 */
236extern GLboolean XMesaUnbindContext( XMesaContext c );
237
238
239/*
jtgafb833d1999-08-19 00:55:39 +0000240 * Return a handle to the current context.
241 */
242extern XMesaContext XMesaGetCurrentContext( void );
243
244
245/*
Brian Paul2257a121999-11-24 18:36:14 +0000246 * Return handle to the current (draw) buffer.
jtgafb833d1999-08-19 00:55:39 +0000247 */
248extern XMesaBuffer XMesaGetCurrentBuffer( void );
249
250
251/*
Brian Paul2257a121999-11-24 18:36:14 +0000252 * Return handle to the current read buffer.
253 * New in Mesa 3.3
254 */
255extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
256
257
258/*
jtgafb833d1999-08-19 00:55:39 +0000259 * Swap the front and back buffers for the given buffer. No action is
260 * taken if the buffer is not double buffered.
261 */
262extern void XMesaSwapBuffers( XMesaBuffer b );
263
264
265/*
266 * Copy a sub-region of the back buffer to the front buffer.
267 *
268 * New in Mesa 2.6
269 */
270extern void XMesaCopySubBuffer( XMesaBuffer b,
271 int x,
272 int y,
273 int width,
274 int height );
275
276
277/*
278 * Return a pointer to the the Pixmap or XImage being used as the back
279 * color buffer of an XMesaBuffer. This function is a way to get "under
280 * the hood" of X/Mesa so one can manipulate the back buffer directly.
281 * Input: b - the XMesaBuffer
282 * Output: pixmap - pointer to back buffer's Pixmap, or 0
283 * ximage - pointer to back buffer's XImage, or NULL
284 * Return: GL_TRUE = context is double buffered
285 * GL_FALSE = context is single buffered
286 */
287extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
288 XMesaPixmap *pixmap,
289 XMesaImage **ximage );
290
291
292
293/*
294 * Return the depth buffer associated with an XMesaBuffer.
295 * Input: b - the XMesa buffer handle
296 * Output: width, height - size of buffer in pixels
297 * bytesPerValue - bytes per depth value (2 or 4)
298 * buffer - pointer to depth buffer values
299 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
300 *
301 * New in Mesa 2.4.
302 */
303extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
304 GLint *width,
305 GLint *height,
306 GLint *bytesPerValue,
307 void **buffer );
308
309
310
311/*
312 * Flush/sync a context
313 */
314extern void XMesaFlush( XMesaContext c );
315
316
317
318/*
319 * Get an X/Mesa-specific string.
320 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
321 */
322extern const char *XMesaGetString( XMesaContext c, int name );
323
324
325
326/*
327 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
328 * any memory used by that buffer.
329 *
330 * New in Mesa 2.3.
331 */
332extern void XMesaGarbageCollect( void );
333
334
335
336/*
337 * Return a dithered pixel value.
338 * Input: c - XMesaContext
339 * x, y - window coordinate
340 * red, green, blue, alpha - color components in [0,1]
341 * Return: pixel value
342 *
343 * New in Mesa 2.3.
344 */
345extern unsigned long XMesaDitherColor( XMesaContext xmesa,
346 GLint x,
347 GLint y,
348 GLfloat red,
349 GLfloat green,
350 GLfloat blue,
351 GLfloat alpha );
352
353
354
355/*
356 * 3Dfx Glide driver only!
357 * Set 3Dfx/Glide full-screen or window rendering mode.
358 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
359 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
360 * Return: GL_TRUE if success
361 * GL_FALSE if invalid mode or if not using 3Dfx driver
362 *
363 * New in Mesa 2.6.
364 */
365extern GLboolean XMesaSetFXmode( GLint mode );
366
367
368
369#ifdef __cplusplus
370}
371#endif
372
373
374#endif