blob: a61258d1c7b5d78896e4940b660fb48912d09e16 [file] [log] [blame]
Brian Paul4049cd32000-01-13 17:40:12 +00001/* $Id: xmesa.h,v 1.4 2000/01/13 17:40:12 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 *
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
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"
Brian Paul4049cd32000-01-13 17:40:12 +000082#ifdef GLX_DIRECT_RENDERING
83#include "dri_mesa.h"
84#endif
jtgafb833d1999-08-19 00:55:39 +000085#endif
86#include "GL/gl.h"
87
88#ifdef AMIWIN
89#include <pragmas/xlib_pragmas.h>
90extern struct Library *XLibBase;
91#endif
92
93
94#define XMESA_MAJOR_VERSION 3
Brian Paul2257a121999-11-24 18:36:14 +000095#define XMESA_MINOR_VERSION 3
jtgafb833d1999-08-19 00:55:39 +000096
97
98
99/*
100 * Values passed to XMesaGetString:
101 */
102#define XMESA_VERSION 1
103#define XMESA_EXTENSIONS 2
104
105
106/*
107 * Values passed to XMesaSetFXmode:
108 */
109#define XMESA_FX_WINDOW 1
110#define XMESA_FX_FULLSCREEN 2
111
112
113
114typedef struct xmesa_context *XMesaContext;
115
116typedef struct xmesa_visual *XMesaVisual;
117
118typedef struct xmesa_buffer *XMesaBuffer;
119
Brian Paul4049cd32000-01-13 17:40:12 +0000120#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
121/*
122 * Initialize the XMesa driver.
123 */
124extern GLboolean XMesaInitDriver( __DRIscreenPrivate *driScrnPriv );
125
126/*
127 * Reset the XMesa driver when the X server resets.
128 */
129extern void XMesaResetDriver( __DRIscreenPrivate *driScrnPriv );
130#endif
jtgafb833d1999-08-19 00:55:39 +0000131
132
133
134/*
135 * Create a new X/Mesa visual.
136 * Input: display - X11 display
137 * visinfo - an XVisualInfo pointer
138 * rgb_flag - GL_TRUE = RGB mode,
139 * GL_FALSE = color index mode
140 * alpha_flag - alpha buffer requested?
141 * db_flag - GL_TRUE = double-buffered,
142 * GL_FALSE = single buffered
143 * stereo_flag - stereo visual?
144 * depth_size - requested bits/depth values, or zero
145 * stencil_size - requested bits/stencil values, or zero
146 * accum_size - requested bits/component values, or zero
147 * ximage_flag - GL_TRUE = use an XImage for back buffer,
148 * GL_FALSE = use an off-screen pixmap for back buffer
149 * Return; a new XMesaVisual or 0 if error.
150 */
151extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
152 XMesaVisualInfo visinfo,
153 GLboolean rgb_flag,
154 GLboolean alpha_flag,
155 GLboolean db_flag,
156 GLboolean stereo_flag,
157 GLboolean ximage_flag,
158 GLint depth_size,
159 GLint stencil_size,
160 GLint accum_size,
161 GLint level );
162
163/*
164 * Destroy an XMesaVisual, but not the associated XVisualInfo.
165 */
166extern void XMesaDestroyVisual( XMesaVisual v );
167
168
169
170/*
171 * Create a new XMesaContext for rendering into an X11 window.
172 *
173 * Input: visual - an XMesaVisual
174 * share_list - another XMesaContext with which to share display
175 * lists or NULL if no sharing is wanted.
176 * Return: an XMesaContext or NULL if error.
177 */
178extern XMesaContext XMesaCreateContext( XMesaVisual v,
Brian Paul4049cd32000-01-13 17:40:12 +0000179 XMesaContext share_list
180#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
181 , __DRIcontextPrivate *driContextPriv
182#endif
183 );
jtgafb833d1999-08-19 00:55:39 +0000184
185
186/*
187 * Destroy a rendering context as returned by XMesaCreateContext()
188 */
189extern void XMesaDestroyContext( XMesaContext c );
190
191
192/*
193 * Create an XMesaBuffer from an X window.
194 */
195extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
Brian Paul4049cd32000-01-13 17:40:12 +0000196 XMesaWindow w
197#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
198 , __DRIdrawablePrivate *driDrawPriv
199#endif
200 );
jtgafb833d1999-08-19 00:55:39 +0000201
202
203/*
204 * Create an XMesaBuffer from an X pixmap.
205 */
206extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
207 XMesaPixmap p,
Brian Paul4049cd32000-01-13 17:40:12 +0000208 XMesaColormap cmap
209#if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server)
210 , __DRIdrawablePrivate *driDrawPriv
211#endif
212 );
jtgafb833d1999-08-19 00:55:39 +0000213
214
215/*
216 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
217 */
218extern void XMesaDestroyBuffer( XMesaBuffer b );
219
220
221/*
222 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
223 *
224 * New in Mesa 2.3.
225 */
226extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
227 XMesaDrawable d );
228
229
230
231/*
232 * Bind a buffer to a context and make the context the current one.
233 */
234extern GLboolean XMesaMakeCurrent( XMesaContext c,
235 XMesaBuffer b );
236
237
238/*
Brian Paul2257a121999-11-24 18:36:14 +0000239 * Bind two buffers (read and draw) to a context and make the
240 * context the current one.
241 * New in Mesa 3.3
242 */
243extern GLboolean XMesaMakeCurrent2( XMesaContext c,
244 XMesaBuffer drawBuffer,
245 XMesaBuffer readBuffer );
246
247
248/*
jtgafb833d1999-08-19 00:55:39 +0000249 * Return a handle to the current context.
250 */
251extern XMesaContext XMesaGetCurrentContext( void );
252
253
254/*
Brian Paul2257a121999-11-24 18:36:14 +0000255 * Return handle to the current (draw) buffer.
jtgafb833d1999-08-19 00:55:39 +0000256 */
257extern XMesaBuffer XMesaGetCurrentBuffer( void );
258
259
260/*
Brian Paul2257a121999-11-24 18:36:14 +0000261 * Return handle to the current read buffer.
262 * New in Mesa 3.3
263 */
264extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
265
266
267/*
jtgafb833d1999-08-19 00:55:39 +0000268 * Swap the front and back buffers for the given buffer. No action is
269 * taken if the buffer is not double buffered.
270 */
271extern void XMesaSwapBuffers( XMesaBuffer b );
272
273
274/*
275 * Copy a sub-region of the back buffer to the front buffer.
276 *
277 * New in Mesa 2.6
278 */
279extern void XMesaCopySubBuffer( XMesaBuffer b,
280 int x,
281 int y,
282 int width,
283 int height );
284
285
286/*
287 * Return a pointer to the the Pixmap or XImage being used as the back
288 * color buffer of an XMesaBuffer. This function is a way to get "under
289 * the hood" of X/Mesa so one can manipulate the back buffer directly.
290 * Input: b - the XMesaBuffer
291 * Output: pixmap - pointer to back buffer's Pixmap, or 0
292 * ximage - pointer to back buffer's XImage, or NULL
293 * Return: GL_TRUE = context is double buffered
294 * GL_FALSE = context is single buffered
295 */
296extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
297 XMesaPixmap *pixmap,
298 XMesaImage **ximage );
299
300
301
302/*
303 * Return the depth buffer associated with an XMesaBuffer.
304 * Input: b - the XMesa buffer handle
305 * Output: width, height - size of buffer in pixels
306 * bytesPerValue - bytes per depth value (2 or 4)
307 * buffer - pointer to depth buffer values
308 * Return: GL_TRUE or GL_FALSE to indicate success or failure.
309 *
310 * New in Mesa 2.4.
311 */
312extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
313 GLint *width,
314 GLint *height,
315 GLint *bytesPerValue,
316 void **buffer );
317
318
319
320/*
321 * Flush/sync a context
322 */
323extern void XMesaFlush( XMesaContext c );
324
325
326
327/*
328 * Get an X/Mesa-specific string.
329 * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
330 */
331extern const char *XMesaGetString( XMesaContext c, int name );
332
333
334
335/*
336 * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
337 * any memory used by that buffer.
338 *
339 * New in Mesa 2.3.
340 */
341extern void XMesaGarbageCollect( void );
342
343
344
345/*
346 * Return a dithered pixel value.
347 * Input: c - XMesaContext
348 * x, y - window coordinate
349 * red, green, blue, alpha - color components in [0,1]
350 * Return: pixel value
351 *
352 * New in Mesa 2.3.
353 */
354extern unsigned long XMesaDitherColor( XMesaContext xmesa,
355 GLint x,
356 GLint y,
357 GLfloat red,
358 GLfloat green,
359 GLfloat blue,
360 GLfloat alpha );
361
362
363
364/*
365 * 3Dfx Glide driver only!
366 * Set 3Dfx/Glide full-screen or window rendering mode.
367 * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
368 * XMESA_FX_FULLSCREEN (full-screen rendering mode)
369 * Return: GL_TRUE if success
370 * GL_FALSE if invalid mode or if not using 3Dfx driver
371 *
372 * New in Mesa 2.6.
373 */
374extern GLboolean XMesaSetFXmode( GLint mode );
375
376
377
378#ifdef __cplusplus
379}
380#endif
381
382
383#endif