replace GLint with GLsizei in a gluScaleImage, gluBuild1/2DMipmaps()
[mesa.git] / include / GL / xmesa.h
1 /* $Id: xmesa.h,v 1.1 1999/08/19 00:55:40 jtg Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
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.1 1999/08/19 00:55:40 jtg
31 * Initial revision
32 *
33 * Revision 1.3 1999/02/24 22:43:27 jens
34 * Name changes to get XMesa to compile standalone inside XFree86
35 *
36 * Revision 1.2 1999/02/14 03:39:09 brianp
37 * new copyright
38 *
39 * Revision 1.1 1998/02/13 03:17:32 brianp
40 * Initial revision
41 *
42 */
43
44
45 /*
46 * Mesa/X11 interface. This header file serves as the documentation for
47 * the Mesa/X11 interface functions.
48 *
49 * Note: this interface isn't intended for user programs. It's primarily
50 * just for implementing the pseudo-GLX interface.
51 */
52
53
54 /* Sample Usage:
55
56 In addition to the usual X calls to select a visual, create a colormap
57 and create a window, you must do the following to use the X/Mesa interface:
58
59 1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
60
61 2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
62 the XMesaVisual.
63
64 3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
65 and XMesaVisual.
66
67 4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
68 to make the context the current one.
69
70 5. Make gl* calls to render your graphics.
71
72 6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
73
74 7. Before the X window is destroyed, call XMesaDestroyBuffer().
75
76 8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
77
78 See the demos/xdemo.c and xmesa1.c files for examples.
79 */
80
81
82
83
84 #ifndef XMESA_H
85 #define XMESA_H
86
87
88 #ifdef __cplusplus
89 extern "C" {
90 #endif
91
92
93 #ifdef XFree86Server
94 #include "xmesa_xf86.h"
95 #else
96 #include <X11/Xlib.h>
97 #include <X11/Xutil.h>
98 #include "xmesa_x.h"
99 #endif
100 #include "GL/gl.h"
101
102 #ifdef AMIWIN
103 #include <pragmas/xlib_pragmas.h>
104 extern struct Library *XLibBase;
105 #endif
106
107
108 #define XMESA_MAJOR_VERSION 3
109 #define XMESA_MINOR_VERSION 0
110
111
112
113 /*
114 * Values passed to XMesaGetString:
115 */
116 #define XMESA_VERSION 1
117 #define XMESA_EXTENSIONS 2
118
119
120 /*
121 * Values passed to XMesaSetFXmode:
122 */
123 #define XMESA_FX_WINDOW 1
124 #define XMESA_FX_FULLSCREEN 2
125
126
127
128 typedef struct xmesa_context *XMesaContext;
129
130 typedef struct xmesa_visual *XMesaVisual;
131
132 typedef struct xmesa_buffer *XMesaBuffer;
133
134
135
136
137 /*
138 * Create a new X/Mesa visual.
139 * Input: display - X11 display
140 * visinfo - an XVisualInfo pointer
141 * rgb_flag - GL_TRUE = RGB mode,
142 * GL_FALSE = color index mode
143 * alpha_flag - alpha buffer requested?
144 * db_flag - GL_TRUE = double-buffered,
145 * GL_FALSE = single buffered
146 * stereo_flag - stereo visual?
147 * depth_size - requested bits/depth values, or zero
148 * stencil_size - requested bits/stencil values, or zero
149 * accum_size - requested bits/component values, or zero
150 * ximage_flag - GL_TRUE = use an XImage for back buffer,
151 * GL_FALSE = use an off-screen pixmap for back buffer
152 * Return; a new XMesaVisual or 0 if error.
153 */
154 extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display,
155 XMesaVisualInfo visinfo,
156 GLboolean rgb_flag,
157 GLboolean alpha_flag,
158 GLboolean db_flag,
159 GLboolean stereo_flag,
160 GLboolean ximage_flag,
161 GLint depth_size,
162 GLint stencil_size,
163 GLint accum_size,
164 GLint level );
165
166 /*
167 * Destroy an XMesaVisual, but not the associated XVisualInfo.
168 */
169 extern void XMesaDestroyVisual( XMesaVisual v );
170
171
172
173 /*
174 * Create a new XMesaContext for rendering into an X11 window.
175 *
176 * Input: visual - an XMesaVisual
177 * share_list - another XMesaContext with which to share display
178 * lists or NULL if no sharing is wanted.
179 * Return: an XMesaContext or NULL if error.
180 */
181 extern XMesaContext XMesaCreateContext( XMesaVisual v,
182 XMesaContext share_list );
183
184
185 /*
186 * Destroy a rendering context as returned by XMesaCreateContext()
187 */
188 extern void XMesaDestroyContext( XMesaContext c );
189
190
191 /*
192 * Create an XMesaBuffer from an X window.
193 */
194 extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v,
195 XMesaWindow w );
196
197
198 /*
199 * Create an XMesaBuffer from an X pixmap.
200 */
201 extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
202 XMesaPixmap p,
203 XMesaColormap cmap );
204
205
206 /*
207 * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
208 */
209 extern void XMesaDestroyBuffer( XMesaBuffer b );
210
211
212 /*
213 * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
214 *
215 * New in Mesa 2.3.
216 */
217 extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
218 XMesaDrawable d );
219
220
221
222 /*
223 * Bind a buffer to a context and make the context the current one.
224 */
225 extern GLboolean XMesaMakeCurrent( XMesaContext c,
226 XMesaBuffer b );
227
228
229 /*
230 * Return a handle to the current context.
231 */
232 extern XMesaContext XMesaGetCurrentContext( void );
233
234
235 /*
236 * Return handle to the current buffer.
237 */
238 extern XMesaBuffer XMesaGetCurrentBuffer( void );
239
240
241 /*
242 * Swap the front and back buffers for the given buffer. No action is
243 * taken if the buffer is not double buffered.
244 */
245 extern 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 */
253 extern 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 */
270 extern 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 */
286 extern 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 */
297 extern 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 */
305 extern 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 */
315 extern 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 */
328 extern 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 */
348 extern GLboolean XMesaSetFXmode( GLint mode );
349
350
351
352 #ifdef __cplusplus
353 }
354 #endif
355
356
357 #endif