1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
18 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 * The above copyright notice and this permission notice (including the
23 * next paragraph) shall be included in all copies or substantial portions
27 **************************************************************************/
35 #include "xm_winsys.h"
40 /* Todo, replace all this with callback-structs provided by the
41 * individual implementations.
50 /* advertise OpenGL support */
51 PUBLIC
const int st_api_OpenGL
= 1;
53 static enum mode
get_mode()
56 if (!getenv("GALLIUM_NOCELL"))
60 #if defined(GALLIUM_LLVMPIPE)
67 static void _init( void ) __attribute__((constructor
));
69 static void _init( void )
71 enum mode xlib_mode
= get_mode();
75 #if defined(GALLIUM_CELL)
76 xmesa_set_driver( &xlib_cell_driver
);
80 #if defined(GALLIUM_LLVMPIPE)
81 xmesa_set_driver( &xlib_llvmpipe_driver
);
85 #if defined(GALLIUM_SOFTPIPE)
86 xmesa_set_driver( &xlib_softpipe_driver
);
96 /***********************************************************************
98 * Butt-ugly hack to convince the linker not to throw away public GL
99 * symbols (they are all referenced from getprocaddress, I guess).
101 extern void (*linker_foo(const unsigned char *procName
))();
102 extern void (*glXGetProcAddress(const unsigned char *procName
))();
104 extern void (*linker_foo(const unsigned char *procName
))()
106 return glXGetProcAddress(procName
);
111 * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in
112 * libglapi.a. We need to define them here.
114 #ifdef GLX_INDIRECT_RENDERING
116 #define GL_GLEXT_PROTOTYPES
118 #include "glapi/glapi.h"
119 #include "glapi/glapitable.h"
120 #include "glapi/glapidispatch.h"
122 #if defined(USE_MGL_NAMESPACE)
123 #define NAME(func) mgl##func
125 #define NAME(func) gl##func
128 #define DISPATCH(FUNC, ARGS, MESSAGE) \
129 CALL_ ## FUNC(GET_DISPATCH(), ARGS);
131 #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
132 return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
134 /* skip normal ones */
135 #define _GLAPI_SKIP_NORMAL_ENTRY_POINTS
136 #include "glapi/glapitemp.h"
138 #endif /* GLX_INDIRECT_RENDERING */