2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
28 * \brief Mini GLX interface functions.
31 * See comments miniglx.c for more information.
47 * \name Replacement Xlib/GLX types
51 * \brief Boolean type.
53 * It can have the values #True or #False.
60 * Alias for private ::MiniGLXColormapRec structure.
62 typedef struct MiniGLXColormapRec
*Colormap
;
65 * \brief Window attributes.
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
;
77 * Alias for the private ::MiniGLXVisualRec structure.
81 typedef struct MiniGLXVisualRec Visual
;
84 * \brief Visual information.
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 */
97 int class; /**< \brief class */
99 int bits_per_rgb
; /**< \brief total bits per pixel */
103 * \brief GLX Frame Buffer Configuration (for pbuffers)
104 * \sa \ref datatypes.
106 typedef struct MiniGLXFBConfigRec
{
107 XVisualInfo
*visInfo
;
112 * \brief Display handle.
114 * Alias for the private ::MiniGLXDisplayRec structure.
116 * \sa \ref datatypes.
118 typedef struct MiniGLXDisplayRec Display
;
121 * \brief Window handle.
123 * Alias for the private ::MiniGLXWindowRec structure.
125 * \sa \ref datatypes.
127 typedef struct MiniGLXWindowRec
*Window
;
132 * Alias for the private ::MiniGLXWindowRec structure.
134 * For Mini GLX only the full-screen window can be used as source and
135 * destination in graphics operations.
137 * \sa \ref datatypes.
139 typedef struct MiniGLXWindowRec
*Drawable
;
142 * \brief GLX drawable.
144 * Alias for the private ::MiniGLXWindowRec structure.
148 * \sa \ref datatypes.
150 typedef struct MiniGLXWindowRec
*GLXDrawable
;
153 * \brief GLX pbuffer.
155 * Alias for the private ::MiniGLXWindowRec structure.
159 * \sa \ref datatypes.
161 typedef struct MiniGLXWindowRec
*GLXPbuffer
;
164 * \brief GLX context.
166 * Alias for the private ::MiniGLXContext structure.
168 * \sa \ref datatypes.
170 typedef struct MiniGLXContextRec
*GLXContext
;
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 */
182 int count
; /* if non-zero, at least this many more */
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
;
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 */
205 } XDestroyWindowEvent
;
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 */
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 */
224 Bool override_redirect
; /* boolean, is override set... */
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 */
237 typedef union _XEvent
{
238 int type
; /* must not be changed; first element */
239 XExposeEvent xexpose
;
240 XCreateWindowEvent xcreatewindow
;
241 XDestroyWindowEvent xdestroywindow
;
244 XMapRequestEvent xmaprequest
;
250 * \name Xlib constants
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
266 #define VisualScreenMask 0x2
268 #define CreateNotify 16
269 #define DestroyNotify 17
270 #define UnmapNotify 18
272 #define MapRequest 20
277 * \name Standard GLX tokens
281 #define GLX_BUFFER_SIZE 2
284 #define GLX_DOUBLEBUFFER 5
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
303 * \name Unique to Mini GLX
305 * At compile time, the Mini GLX interface version can be tested with the
306 * MINI_GLX_VERSION_1_x preprocessor tokens.
308 * \sa glXQueryVersion()
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
319 * \name Server-specific functions
322 __miniglx_StartServer( const char *display_name
);
325 __miniglx_Select( Display
*dpy
, int maxfd
,
326 fd_set
*rfds
, fd_set
*wfds
, fd_set
*xfds
,
327 struct timeval
*tv
);
331 * \name Simulated Xlib functions
335 XOpenDisplay( const char *dpy_name
);
339 XCloseDisplay( Display
*display
);
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
);
349 XNextEvent(Display
*display
, XEvent
*event_return
);
352 XCheckMaskEvent( Display
*dpy
, long event_mask
, XEvent
*event_return
);
355 * \brief Return the root window.
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.
362 * \return the root window. Always zero on Mini GLX.
364 #define RootWindow(display, screen) 0
365 #define DefaultScreen(dpy) 0
368 XDestroyWindow( Display
*display
, Window w
);
371 XMapWindow( Display
*display
, Window w
);
373 /* Should clients have access to this?
376 XUnmapWindow( Display
*display
, Window w
);
379 XCreateColormap( Display
*display
, Window w
, Visual
*visual
, int alloc
);
382 XFreeColormap( Display
*display
, Colormap cmap
);
388 XGetVisualInfo( Display
*display
, long vinfo_mask
,
389 XVisualInfo
*vinfo_template
, int *nitems_return
);
395 * \name GLX functions
399 glXChooseVisual( Display
*dpy
, int screen
, int *attribList
);
402 glXGetConfig( Display
*dpy
, XVisualInfo
*vis
, int attrib
, int *value
);
405 glXCreateContext( Display
*dpy
, XVisualInfo
*vis
,
406 GLXContext shareList
, Bool direct
);
409 glXDestroyContext( Display
*dpy
, GLXContext ctx
);
412 glXMakeCurrent( Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
);
415 glXSwapBuffers( Display
*dpy
, GLXDrawable drawable
);
418 glXGetCurrentContext( void );
421 glXGetCurrentDrawable( void );
424 (*glXGetProcAddress(const GLubyte
*procname
))( void );
427 glXQueryVersion( Display
*dpy
, int *major
, int *minor
);
429 /* Added in MiniGLX 1.1 */
431 glXCreatePbuffer( Display
*dpy
, GLXFBConfig config
, const int *attribList
);
434 glXDestroyPbuffer( Display
*dpy
, GLXPbuffer pbuf
);
437 glXChooseFBConfig( Display
*dpy
, int screen
, const int *attribList
,
441 glXGetVisualFromFBConfig( Display
*dpy
, GLXFBConfig config
);
450 #endif /* MINIGLX_H */