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.
55 #ifndef MINIGLX_NO_XTYPES
58 typedef int MINI_Bool
;
63 * Alias for private ::MiniGLXColormapRec structure.
65 typedef struct MiniGLXColormapRec
*MINI_Colormap
;
66 #ifndef MINIGLX_NO_XTYPES
67 typedef struct MiniGLXColormapRec
*Colormap
;
71 * \brief Window attributes.
73 typedef struct MiniGLXSetWindowAttributesRec
{
74 int background_pixel
; /**< \brief background pixel */
75 int border_pixel
; /**< \brief border pixel value */
76 MINI_Colormap colormap
; /**< \brief color map to be associated with window */
77 int event_mask
; /**< \brief set of events that should be saved */
78 } XSetWindowAttributes
;
83 * Alias for the private ::MiniGLXVisualRec structure.
87 typedef struct MiniGLXVisualRec Visual
;
90 * \brief Visual information.
94 #ifndef MINIGLX_NO_XTYPES
95 typedef unsigned long VisualID
;
97 typedef unsigned long MINI_VisualID
;
98 typedef struct MiniGLXXVisualInfoRec
{
99 Visual
*visual
; /**< \brief pointer to the GLX Visual */
100 MINI_VisualID visualid
; /**< \brief visual ID */
101 int screen
; /**< \brief screen number */
102 int depth
; /**< \brief bit depth */
103 #if defined(__cplusplus) || defined(c_plusplus)
104 int c_class
; /**< \brief class */
106 int class; /**< \brief class */
108 int bits_per_rgb
; /**< \brief total bits per pixel */
112 * \brief GLX Frame Buffer Configuration (for pbuffers)
113 * \sa \ref datatypes.
115 typedef struct MiniGLXFBConfigRec
{
116 XVisualInfo
*visInfo
;
121 * \brief Display handle.
123 * Alias for the private ::MiniGLXDisplayRec structure.
125 * \sa \ref datatypes.
127 #ifndef MINIGLX_NO_XTYPES
128 typedef struct MiniGLXDisplayRec Display
;
130 typedef struct MiniGLXDisplayRec MINI_Display
;
133 * \brief Window handle.
135 * Alias for the private ::MiniGLXWindowRec structure.
137 * \sa \ref datatypes.
139 #ifndef MINIGLX_NO_XTYPES
140 typedef struct MiniGLXWindowRec
*Window
;
142 typedef struct MiniGLXWindowRec
*MINI_Window
;
147 * Alias for the private ::MiniGLXWindowRec structure.
149 * For Mini GLX only the full-screen window can be used as source and
150 * destination in graphics operations.
152 * \sa \ref datatypes.
154 #ifndef MINIGLX_NO_XTYPES
155 typedef struct MiniGLXWindowRec
*Drawable
;
157 typedef struct MiniGLXWindowRec
*MINI_Drawable
;
160 * \brief GLX drawable.
162 * Alias for the private ::MiniGLXWindowRec structure.
166 * \sa \ref datatypes.
168 typedef struct MiniGLXWindowRec
*GLXDrawable
;
171 * \brief GLX pbuffer.
173 * Alias for the private ::MiniGLXWindowRec structure.
177 * \sa \ref datatypes.
179 typedef struct MiniGLXWindowRec
*GLXPbuffer
;
182 * \brief GLX context.
184 * Alias for the private ::MiniGLXContext structure.
186 * \sa \ref datatypes.
188 typedef struct MiniGLXContextRec
*GLXContext
;
194 unsigned long serial
; /* # of last request processed by server */
195 MINI_Bool send_event
; /* true if this came from a SendEvent request */
196 MINI_Display
*display
; /* Display the event was read from */
200 int count
; /* if non-zero, at least this many more */
205 unsigned long serial
; /* # of last request processed by server */
206 MINI_Bool send_event
; /* true if this came from a SendEvent request */
207 MINI_Display
*display
; /* Display the event was read from */
208 MINI_Window parent
; /* parent of the window */
209 MINI_Window window
; /* window id of window created */
210 int x
, y
; /* window location */
211 int width
, height
; /* size of window */
212 int border_width
; /* border width */
213 MINI_Bool override_redirect
; /* creation should be overridden */
214 } XCreateWindowEvent
;
218 unsigned long serial
; /* # of last request processed by server */
219 MINI_Bool send_event
; /* true if this came from a SendEvent request */
220 MINI_Display
*display
; /* Display the event was read from */
223 } XDestroyWindowEvent
;
227 unsigned long serial
; /* # of last request processed by server */
228 MINI_Bool send_event
; /* true if this came from a SendEvent request */
229 MINI_Display
*display
; /* Display the event was read from */
232 MINI_Bool from_configure
;
237 unsigned long serial
; /* # of last request processed by server */
238 MINI_Bool send_event
; /* true if this came from a SendEvent request */
239 MINI_Display
*display
; /* Display the event was read from */
242 MINI_Bool override_redirect
; /* boolean, is override set... */
248 unsigned long serial
; /* # of last request processed by server */
249 MINI_Bool send_event
; /* true if this came from a SendEvent request */
250 MINI_Display
*display
; /* Display the event was read from */
255 typedef union _XEvent
{
256 int type
; /* must not be changed; first element */
257 XExposeEvent xexpose
;
258 XCreateWindowEvent xcreatewindow
;
259 XDestroyWindowEvent xdestroywindow
;
262 XMapRequestEvent xmaprequest
;
268 * \name Xlib constants
275 #define InputOutput 1
276 #define ExposureMask (1L<<15)
277 #define StructureNotifyMask (1L<<17)
278 #define CWBackPixel (1L<<1)
279 #define CWBorderPixel (1L<<3)
280 #define CWEventMask (1L<<11)
281 #define CWColormap (1L<<13)
282 #define PseudoColor 3
284 #define VisualIDMask 0x1
285 #define VisualScreenMask 0x2
287 #define CreateNotify 16
288 #define DestroyNotify 17
289 #define UnmapNotify 18
291 #define MapRequest 20
296 * \name Standard GLX tokens
300 #define GLX_BUFFER_SIZE 2
303 #define GLX_DOUBLEBUFFER 5
305 #define GLX_AUX_BUFFERS 7
306 #define GLX_RED_SIZE 8
307 #define GLX_GREEN_SIZE 9
308 #define GLX_BLUE_SIZE 10
309 #define GLX_ALPHA_SIZE 11
310 #define GLX_DEPTH_SIZE 12
311 #define GLX_STENCIL_SIZE 13
312 #define GLX_ACCUM_RED_SIZE 14
313 #define GLX_ACCUM_GREEN_SIZE 15
314 #define GLX_ACCUM_BLUE_SIZE 16
315 #define GLX_ACCUM_ALPHA_SIZE 17
316 #define GLX_BAD_ATTRIBUTE 1
317 #define GLX_BAD_VISUAL 4
322 * \name Unique to Mini GLX
324 * At compile time, the Mini GLX interface version can be tested with the
325 * MINI_GLX_VERSION_1_x preprocessor tokens.
327 * \sa glXQueryVersion()
330 /** \brief Defined if version 1.0 of Mini GLX is supported. */
331 #define MINI_GLX_VERSION_1_0 1
332 /** \brief Defined if version 1.1 of Mini GLX is supported. */
333 #define MINI_GLX_VERSION_1_1 1
338 * \name Server-specific functions
340 extern MINI_Display
*
341 __miniglx_StartServer( const char *display_name
);
344 __miniglx_Select( MINI_Display
*dpy
, int maxfd
,
345 fd_set
*rfds
, fd_set
*wfds
, fd_set
*xfds
,
346 struct timeval
*tv
);
350 * \name Simulated Xlib functions
353 extern MINI_Display
*
354 XOpenDisplay( const char *dpy_name
);
358 XCloseDisplay( MINI_Display
*display
);
361 XCreateWindow( MINI_Display
*display
, MINI_Window parent
, int x
, int y
,
362 unsigned int width
, unsigned int height
,
363 unsigned int border_width
, int depth
, unsigned int winclass
,
364 Visual
*visual
, unsigned long valuemask
,
365 XSetWindowAttributes
*attributes
);
368 XNextEvent(MINI_Display
*display
, XEvent
*event_return
);
371 XCheckMaskEvent( MINI_Display
*dpy
, long event_mask
, XEvent
*event_return
);
374 * \brief Return the root window.
376 * \param display the display handle. It is ignored by Mini GLX, but should be
377 * the value returned by XOpenDisplay().
378 * \param screen the screen number on the host server. It is ignored by Mini
379 * GLX but should be zero.
381 * \return the root window. Always zero on Mini GLX.
383 #define RootWindow(display, screen) 0
384 #define DefaultScreen(dpy) 0
387 XDestroyWindow( MINI_Display
*display
, MINI_Window w
);
390 XMapWindow( MINI_Display
*display
, MINI_Window w
);
392 /* Should clients have access to this?
395 XUnmapWindow( MINI_Display
*display
, MINI_Window w
);
398 XCreateColormap( MINI_Display
*display
, MINI_Window w
, Visual
*visual
, int alloc
);
401 XFreeColormap( MINI_Display
*display
, MINI_Colormap cmap
);
407 XGetVisualInfo( MINI_Display
*display
, long vinfo_mask
,
408 XVisualInfo
*vinfo_template
, int *nitems_return
);
414 * \name GLX functions
418 glXChooseVisual( MINI_Display
*dpy
, int screen
, int *attribList
);
421 glXGetConfig( MINI_Display
*dpy
, XVisualInfo
*vis
, int attrib
, int *value
);
424 glXCreateContext( MINI_Display
*dpy
, XVisualInfo
*vis
,
425 GLXContext shareList
, MINI_Bool direct
);
428 glXDestroyContext( MINI_Display
*dpy
, GLXContext ctx
);
431 glXMakeCurrent( MINI_Display
*dpy
, GLXDrawable drawable
, GLXContext ctx
);
434 glXSwapBuffers( MINI_Display
*dpy
, GLXDrawable drawable
);
437 glXGetCurrentContext( void );
440 glXGetCurrentDrawable( void );
443 (*glXGetProcAddress(const GLubyte
*procname
))( void );
446 glXQueryVersion( MINI_Display
*dpy
, int *major
, int *minor
);
448 /* Added in MiniGLX 1.1 */
450 glXCreatePbuffer( MINI_Display
*dpy
, GLXFBConfig config
, const int *attribList
);
453 glXDestroyPbuffer( MINI_Display
*dpy
, GLXPbuffer pbuf
);
456 glXChooseFBConfig( MINI_Display
*dpy
, int screen
, const int *attribList
,
460 glXGetVisualFromFBConfig( MINI_Display
*dpy
, GLXFBConfig config
);
462 extern void *glXAllocateMemoryMESA(Display
*dpy
, int scrn
,
463 size_t size
, float readFreq
,
464 float writeFreq
, float priority
);
466 extern void glXFreeMemoryMESA(Display
*dpy
, int scrn
, void *pointer
);
468 extern GLuint
glXGetMemoryOffsetMESA( Display
*dpy
, int scrn
,
469 const void *pointer
);
473 __glXScrEnableExtension( void *, const char * name
);
482 #endif /* MINIGLX_H */