blob: 313aa23c94c6173444f230349db98d6261c7956b [file] [log] [blame]
Brian Paul5bf7f471999-11-24 18:45:44 +00001/* $Id: xmesa.h,v 1.3 1999/11/24 18:45:44 brianp 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 *
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/*
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
70
71#ifdef __cplusplus
72extern "C" {
73#endif
74
75
76#ifdef XFree86Server
77#include "xmesa_xf86.h"
78#else
79#include <X11/Xlib.h>
80#include <X11/Xutil.h>
81#include "xmesa_x.h"
82#endif
83#include "GL/gl.h"
84
85#ifdef AMIWIN
86#include <pragmas/xlib_pragmas.h>
87extern struct Library *XLibBase;
88#endif
89
90
91#define XMESA_MAJOR_VERSION 3
Brian Paul2257a121999-11-24 18:36:14 +000092#define XMESA_MINOR_VERSION 3
jtgafb833d1999-08-19 00:55:39 +000093
94
95
96/*
97 * Values passed to XMesaGetString:
98 */
99#define XMESA_VERSION 1
100#define XMESA_EXTENSIONS 2
101
102
103/*
104 * Values passed to XMesaSetFXmode:
105 */
106#define XMESA_FX_WINDOW 1
107#define XMESA_FX_FULLSCREEN 2
108
109
110
111typedef struct xmesa_context *XMesaContext;
112
113typedef struct xmesa_visual *XMesaVisual;
114
115typedef struct xmesa_buffer *XMesaBuffer;
116
117
118
119
120/*
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 * depth_size - requested bits/depth values, or zero
131 * stencil_size - requested bits/stencil values, or zero
132 * accum_size - requested bits/component values, or zero
133 * ximage_flag - GL_TRUE = use an XImage for back buffer,
134 * GL_FALSE = use an off-screen pixmap for back buffer
135 * Return; a new XMesaVisual or 0 if error.
136 */
137extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
138 XMesaVisualInfo visinfo,
139 GLboolean rgb_flag,
140 GLboolean alpha_flag,
141 GLboolean db_flag,
142 GLboolean stereo_flag,
143 GLboolean ximage_flag,
144 GLint depth_size,
145 GLint stencil_size,
146 GLint accum_size,
147 GLint level );
148
149/*
150 * Destroy an XMesaVisual, but not the associated XVisualInfo.
151 */
152extern void XMesaDestroyVisual( XMesaVisual v );
153
154
155
156/*
157 * Create a new XMesaContext for rendering into an X11 window.
158 *
159 * Input: visual - an XMesaVisual
160 * share_list - another XMesaContext with which to share display
161 * lists or NULL if no sharing is wanted.
162 * Return: an XMesaContext or NULL if error.
163 */
164extern XMesaContext XMesaCreateContext( XMesaVisual v,
165 XMesaContext share_list );
166
167
168/*
169 * Destroy a rendering context as returned by XMesaCreateContext()
170 */
171extern void XMesaDestroyContext( XMesaContext c );
172
173
174/*
175 * Create an XMesaBuffer from an X window.
176 */
177extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
178 XMesaWindow w );
179
180
181/*
182 * Create an XMesaBuffer from an X pixmap.
183 */
184extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
185 XMesaPixmap p,
186 XMesaColormap cmap );
187
188
189/*
190 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
191 */
192extern void XMesaDestroyBuffer( XMesaBuffer b );
193
194
195/*
196 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
197 *
198 * New in Mesa 2.3.
199 */
200extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
201 XMesaDrawable d );
202
203
204
205/*
206 * Bind a buffer to a context and make the context the current one.
207 */
208extern GLboolean XMesaMakeCurrent( XMesaContext c,
209 XMesaBuffer b );
210
211
212/*
Brian Paul2257a121999-11-24 18:36:14 +0000213 * Bind two buffers (read and draw) to a context and make the
214 * context the current one.
215 * New in Mesa 3.3
216 */
217extern GLboolean XMesaMakeCurrent2( XMesaContext c,
218 XMesaBuffer drawBuffer,
219 XMesaBuffer readBuffer );
220
221
222/*
jtgafb833d1999-08-19 00:55:39 +0000223 * Return a handle to the current context.
224 */
225extern XMesaContext XMesaGetCurrentContext( void );
226
227
228/*
Brian Paul2257a121999-11-24 18:36:14 +0000229 * Return handle to the current (draw) buffer.
jtgafb833d1999-08-19 00:55:39 +0000230 */
231extern XMesaBuffer XMesaGetCurrentBuffer( void );
232
233
234/*
Brian Paul2257a121999-11-24 18:36:14 +0000235 * Return handle to the current read buffer.
236 * New in Mesa 3.3
237 */
238extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
239
240
241/*
jtgafb833d1999-08-19 00:55:39 +0000242 * Swap the front and back buffers for the given buffer. No action is
243 * taken if the buffer is not double buffered.
244 */
245extern void XMesaSwapBuffers( XMesaBuffer b );
246
247
248/*
249 * Copy a sub-region of the back buffer to the front buffer.
250 *
251 * New in Mesa 2.6
252 */
253extern void XMesaCopySubBuffer( XMesaBuffer b,
254 int x,
255 int y,
256 int width,
257 int height );
258
259
260/*
261 * Return a pointer to the the Pixmap or XImage being used as the back
262 * color buffer of an XMesaBuffer. This function is a way to get "under
263 * the hood" of X/Mesa so one can manipulate the back buffer directly.
264 * Input: b - the XMesaBuffer
265 * Output: pixmap - pointer to back buffer's Pixmap, or 0
266 * ximage - pointer to back buffer's XImage, or NULL
267 * Return: GL_TRUE = context is double buffered
268 * GL_FALSE = context is single buffered
269 */
270extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
271 XMesaPixmap *pixmap,
272 XMesaImage **ximage );
273
274
275
276/*
277 * Return the depth buffer associated with an XMesaBuffer.
278 * Input: b - the XMesa buffer handle
279 * Output: width, height - size of buffer in pixels
280 * bytesPerValue - bytes per depth value (2 or 4)
281 * buffer - pointer to depth buffer values
282 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
283 *
284 * New in Mesa 2.4.
285 */
286extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
287 GLint *width,
288 GLint *height,
289 GLint *bytesPerValue,
290 void **buffer );
291
292
293
294/*
295 * Flush/sync a context
296 */
297extern void XMesaFlush( XMesaContext c );
298
299
300
301/*
302 * Get an X/Mesa-specific string.
303 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
304 */
305extern const char *XMesaGetString( XMesaContext c, int name );
306
307
308
309/*
310 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
311 * any memory used by that buffer.
312 *
313 * New in Mesa 2.3.
314 */
315extern void XMesaGarbageCollect( void );
316
317
318
319/*
320 * Return a dithered pixel value.
321 * Input: c - XMesaContext
322 * x, y - window coordinate
323 * red, green, blue, alpha - color components in [0,1]
324 * Return: pixel value
325 *
326 * New in Mesa 2.3.
327 */
328extern unsigned long XMesaDitherColor( XMesaContext xmesa,
329 GLint x,
330 GLint y,
331 GLfloat red,
332 GLfloat green,
333 GLfloat blue,
334 GLfloat alpha );
335
336
337
338/*
339 * 3Dfx Glide driver only!
340 * Set 3Dfx/Glide full-screen or window rendering mode.
341 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
342 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
343 * Return: GL_TRUE if success
344 * GL_FALSE if invalid mode or if not using 3Dfx driver
345 *
346 * New in Mesa 2.6.
347 */
348extern GLboolean XMesaSetFXmode( GLint mode );
349
350
351
352#ifdef __cplusplus
353}
354#endif
355
356
357#endif