Add an install target
[mesa.git] / include / GL / miniglx.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file miniglx.h
28 * \brief Mini GLX interface functions.
29 * \author Brian Paul
30 *
31 * See comments miniglx.c for more information.
32 */
33
34 #ifndef MINIGLX_H
35 #define MINIGLX_H
36
37 #include <GL/gl.h>
38 #include <stdlib.h>
39
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45
46 /**
47 * \name Replacement Xlib/GLX types
48 */
49 /*@{*/
50 /**
51 * \brief Boolean type.
52 *
53 * It can have the values #True or #False.
54 */
55 typedef int Bool;
56
57 /**
58 * \brief Color map.
59 *
60 * Alias for private ::MiniGLXColormapRec structure.
61 */
62 typedef struct MiniGLXColormapRec *Colormap;
63
64 /**
65 * \brief Window attributes.
66 */
67 typedef struct MiniGLXSetWindowAttributesRec {
68 int background_pixel; /**< \brief background pixel */
69 int border_pixel; /**< \brief border pixel value */
70 Colormap colormap; /**< \brief color map to be associated with window */
71 int event_mask; /**< \brief set of events that should be saved */
72 } XSetWindowAttributes;
73
74 /**
75 * \brief Visual.
76 *
77 * Alias for the private ::MiniGLXVisualRec structure.
78 *
79 * \sa \ref datatypes.
80 */
81 typedef struct MiniGLXVisualRec Visual;
82
83 /**
84 * \brief Visual information.
85 *
86 * \sa \ref datatypes.
87 */
88 typedef unsigned int VisualID;
89 typedef struct MiniGLXXVisualInfoRec {
90 Visual *visual; /**< \brief pointer to the GLX Visual */
91 VisualID visualid; /**< \brief visual ID */
92 int screen; /**< \brief screen number */
93 int depth; /**< \brief bit depth */
94 #if defined(__cplusplus) || defined(c_plusplus)
95 int c_class; /**< \brief class */
96 #else
97 int class; /**< \brief class */
98 #endif
99 int bits_per_rgb; /**< \brief total bits per pixel */
100 } XVisualInfo;
101
102 /**
103 * \brief GLX Frame Buffer Configuration (for pbuffers)
104 * \sa \ref datatypes.
105 */
106 typedef struct MiniGLXFBConfigRec {
107 XVisualInfo *visInfo;
108 } GLXFBConfig;
109
110
111 /**
112 * \brief Display handle.
113 *
114 * Alias for the private ::MiniGLXDisplayRec structure.
115 *
116 * \sa \ref datatypes.
117 */
118 typedef struct MiniGLXDisplayRec Display;
119
120 /**
121 * \brief Window handle.
122 *
123 * Alias for the private ::MiniGLXWindowRec structure.
124 *
125 * \sa \ref datatypes.
126 */
127 typedef struct MiniGLXWindowRec *Window;
128
129 /**
130 * \brief Drawable.
131 *
132 * Alias for the private ::MiniGLXWindowRec structure.
133 *
134 * For Mini GLX only the full-screen window can be used as source and
135 * destination in graphics operations.
136 *
137 * \sa \ref datatypes.
138 */
139 typedef struct MiniGLXWindowRec *Drawable;
140
141 /**
142 * \brief GLX drawable.
143 *
144 * Alias for the private ::MiniGLXWindowRec structure.
145 *
146 * Same as #Drawable.
147 *
148 * \sa \ref datatypes.
149 */
150 typedef struct MiniGLXWindowRec *GLXDrawable;
151
152 /**
153 * \brief GLX pbuffer.
154 *
155 * Alias for the private ::MiniGLXWindowRec structure.
156 *
157 * Same as #Drawable.
158 *
159 * \sa \ref datatypes.
160 */
161 typedef struct MiniGLXWindowRec *GLXPbuffer;
162
163 /**
164 * \brief GLX context.
165 *
166 * Alias for the private ::MiniGLXContext structure.
167 *
168 * \sa \ref datatypes.
169 */
170 typedef struct MiniGLXContextRec *GLXContext;
171 /*@}*/
172
173
174 typedef struct {
175 int type;
176 unsigned long serial; /* # of last request processed by server */
177 Bool send_event; /* true if this came from a SendEvent request */
178 Display *display; /* Display the event was read from */
179 Window window;
180 int x, y;
181 int width, height;
182 int count; /* if non-zero, at least this many more */
183 } XExposeEvent;
184
185 typedef struct {
186 int type;
187 unsigned long serial; /* # of last request processed by server */
188 Bool send_event; /* true if this came from a SendEvent request */
189 Display *display; /* Display the event was read from */
190 Window parent; /* parent of the window */
191 Window window; /* window id of window created */
192 int x, y; /* window location */
193 int width, height; /* size of window */
194 int border_width; /* border width */
195 Bool override_redirect; /* creation should be overridden */
196 } XCreateWindowEvent;
197
198 typedef struct {
199 int type;
200 unsigned long serial; /* # of last request processed by server */
201 Bool send_event; /* true if this came from a SendEvent request */
202 Display *display; /* Display the event was read from */
203 Window event;
204 Window window;
205 } XDestroyWindowEvent;
206
207 typedef struct {
208 int type;
209 unsigned long serial; /* # of last request processed by server */
210 Bool send_event; /* true if this came from a SendEvent request */
211 Display *display; /* Display the event was read from */
212 Window event;
213 Window window;
214 Bool from_configure;
215 } XUnmapEvent;
216
217 typedef struct {
218 int type;
219 unsigned long serial; /* # of last request processed by server */
220 Bool send_event; /* true if this came from a SendEvent request */
221 Display *display; /* Display the event was read from */
222 Window event;
223 Window window;
224 Bool override_redirect; /* boolean, is override set... */
225 } XMapEvent;
226
227
228 typedef struct {
229 int type;
230 unsigned long serial; /* # of last request processed by server */
231 Bool send_event; /* true if this came from a SendEvent request */
232 Display *display; /* Display the event was read from */
233 Window parent;
234 Window window;
235 } XMapRequestEvent;
236
237 typedef union _XEvent {
238 int type; /* must not be changed; first element */
239 XExposeEvent xexpose;
240 XCreateWindowEvent xcreatewindow;
241 XDestroyWindowEvent xdestroywindow;
242 XUnmapEvent xunmap;
243 XMapEvent xmap;
244 XMapRequestEvent xmaprequest;
245 long pad[24];
246 } XEvent;
247
248
249 /**
250 * \name Xlib constants
251 */
252 /*@{*/
253 #define False 0
254 #define True 1
255 #define None 0
256 #define AllocNone 0
257 #define InputOutput 1
258 #define ExposureMask (1L<<15)
259 #define StructureNotifyMask (1L<<17)
260 #define CWBackPixel (1L<<1)
261 #define CWBorderPixel (1L<<3)
262 #define CWEventMask (1L<<11)
263 #define CWColormap (1L<<13)
264 #define PseudoColor 3
265 #define TrueColor 4
266 #define VisualScreenMask 0x2
267 #define Expose 12
268 #define CreateNotify 16
269 #define DestroyNotify 17
270 #define UnmapNotify 18
271 #define MapNotify 19
272 #define MapRequest 20
273
274 /*@}*/
275
276 /**
277 * \name Standard GLX tokens
278 */
279 /*@{*/
280 #define GLX_USE_GL 1
281 #define GLX_BUFFER_SIZE 2
282 #define GLX_LEVEL 3
283 #define GLX_RGBA 4
284 #define GLX_DOUBLEBUFFER 5
285 #define GLX_STEREO 6
286 #define GLX_AUX_BUFFERS 7
287 #define GLX_RED_SIZE 8
288 #define GLX_GREEN_SIZE 9
289 #define GLX_BLUE_SIZE 10
290 #define GLX_ALPHA_SIZE 11
291 #define GLX_DEPTH_SIZE 12
292 #define GLX_STENCIL_SIZE 13
293 #define GLX_ACCUM_RED_SIZE 14
294 #define GLX_ACCUM_GREEN_SIZE 15
295 #define GLX_ACCUM_BLUE_SIZE 16
296 #define GLX_ACCUM_ALPHA_SIZE 17
297 #define GLX_BAD_ATTRIBUTE 1
298 #define GLX_BAD_VISUAL 4
299 /*@}*/
300
301
302 /**
303 * \name Unique to Mini GLX
304 *
305 * At compile time, the Mini GLX interface version can be tested with the
306 * MINI_GLX_VERSION_1_x preprocessor tokens.
307 *
308 * \sa glXQueryVersion()
309 */
310 /*@{*/
311 /** \brief Defined if version 1.0 of Mini GLX is supported. */
312 #define MINI_GLX_VERSION_1_0 1
313 /** \brief Defined if version 1.1 of Mini GLX is supported. */
314 #define MINI_GLX_VERSION_1_1 1
315 /*@}*/
316
317
318 /**
319 * \name Server-specific functions
320 */
321 extern Display *
322 __miniglx_StartServer( const char *display_name );
323
324 extern int
325 __miniglx_Select( Display *dpy, int maxfd,
326 fd_set *rfds, fd_set *wfds, fd_set *xfds,
327 struct timeval *tv );
328
329
330 /**
331 * \name Simulated Xlib functions
332 */
333 /*@{*/
334 extern Display *
335 XOpenDisplay( const char *dpy_name );
336
337
338 extern void
339 XCloseDisplay( Display *display );
340
341 extern Window
342 XCreateWindow( Display *display, Window parent, int x, int y,
343 unsigned int width, unsigned int height,
344 unsigned int border_width, int depth, unsigned int winclass,
345 Visual *visual, unsigned long valuemask,
346 XSetWindowAttributes *attributes );
347
348 extern int
349 XNextEvent(Display *display, XEvent *event_return);
350
351 extern Bool
352 XCheckMaskEvent( Display *dpy, long event_mask, XEvent *event_return );
353
354 /**
355 * \brief Return the root window.
356 *
357 * \param display the display handle. It is ignored by Mini GLX, but should be
358 * the value returned by XOpenDisplay().
359 * \param screen the screen number on the host server. It is ignored by Mini
360 * GLX but should be zero.
361 *
362 * \return the root window. Always zero on Mini GLX.
363 */
364 #define RootWindow(display, screen) 0
365 #define DefaultScreen(dpy) 0
366
367 extern void
368 XDestroyWindow( Display *display, Window w );
369
370 extern void
371 XMapWindow( Display *display, Window w );
372
373 /* Should clients have access to this?
374 */
375 extern void
376 XUnmapWindow( Display *display, Window w );
377
378 extern Colormap
379 XCreateColormap( Display *display, Window w, Visual *visual, int alloc );
380
381 extern void
382 XFreeColormap( Display *display, Colormap cmap );
383
384 extern void
385 XFree( void *data );
386
387 extern XVisualInfo *
388 XGetVisualInfo( Display *display, long vinfo_mask,
389 XVisualInfo *vinfo_template, int *nitems_return );
390 /*@}*/
391
392
393
394 /**
395 * \name GLX functions
396 */
397 /*@{*/
398 extern XVisualInfo*
399 glXChooseVisual( Display *dpy, int screen, int *attribList );
400
401 extern int
402 glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value );
403
404 extern GLXContext
405 glXCreateContext( Display *dpy, XVisualInfo *vis,
406 GLXContext shareList, Bool direct );
407
408 extern void
409 glXDestroyContext( Display *dpy, GLXContext ctx );
410
411 extern Bool
412 glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx);
413
414 extern void
415 glXSwapBuffers( Display *dpy, GLXDrawable drawable );
416
417 extern GLXContext
418 glXGetCurrentContext( void );
419
420 extern GLXDrawable
421 glXGetCurrentDrawable( void );
422
423 extern void
424 (*glXGetProcAddress(const GLubyte *procname))( void );
425
426 extern Bool
427 glXQueryVersion( Display *dpy, int *major, int *minor );
428
429 /* Added in MiniGLX 1.1 */
430 extern GLXPbuffer
431 glXCreatePbuffer( Display *dpy, GLXFBConfig config, const int *attribList );
432
433 extern void
434 glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
435
436 extern GLXFBConfig *
437 glXChooseFBConfig( Display *dpy, int screen, const int *attribList,
438 int *nitems );
439
440 extern XVisualInfo *
441 glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
442
443 /*@}*/
444
445
446 #ifdef __cplusplus
447 }
448 #endif
449
450 #endif /* MINIGLX_H */