3 * Top-most include file.
5 * This is the top-most include file of the Mesa sources.
6 * It includes gl.h and all system headers which are needed.
7 * Other Mesa source files should \e not directly include any system
8 * headers. This allows Mesa to be integrated into XFree86 and
9 * allows system-dependent hacks/workarounds to be collected in one place.
11 * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
13 * If you touch this file, everything gets recompiled!
15 * This file should be included before any other header in the .c files.
17 * Put compiler/OS/assembly pragmas and macros here to avoid
18 * cluttering other source files.
22 * Mesa 3-D graphics library
25 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
27 * Permission is hereby granted, free of charge, to any person obtaining a
28 * copy of this software and associated documentation files (the "Software"),
29 * to deal in the Software without restriction, including without limitation
30 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
31 * and/or sell copies of the Software, and to permit persons to whom the
32 * Software is furnished to do so, subject to the following conditions:
34 * The above copyright notice and this permission notice shall be included
35 * in all copies or substantial portions of the Software.
37 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
38 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
39 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
40 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
41 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 #if defined(XFree86LOADER) && defined(IN_MODULE)
51 #include "xf86_ansic.h"
55 /* If we can use Compaq's Fast Math Library on Alpha */
56 #if defined(__alpha__) && defined(CCPML)
65 #if defined(__linux__) && defined(__i386__)
66 #include <fpu_control.h>
73 /* This is no longer uses since we dumped autoconf/automake! */
79 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
81 # define finite _finite
84 #if defined(__WATCOMC__)
85 # define finite _finite
86 # pragma disable_message(201) /* Disable unreachable code warnings */
90 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
91 # if !defined(__GNUC__) /* mingw environment */
92 # pragma warning( disable : 4068 ) /* unknown pragma */
93 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
94 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
95 # pragma warning( disable : 4127 ) /* conditional expression is constant */
96 # if defined(MESA_MINWARN)
97 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
98 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
99 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
100 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
101 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
104 # if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
105 # define WGLAPI __declspec(dllexport)
106 # elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
107 # define WGLAPI __declspec(dllimport)
108 # else /* for use with static link lib build of Win32 edition only */
109 # define WGLAPI __declspec(dllimport)
110 # endif /* _STATIC_MESA support */
111 #endif /* WIN32 / CYGWIN bracket */
115 /* XXX why is this here?
116 * It should probaby be somewhere in src/mesa/drivers/windows/
118 /* compatibility guard so we don't need to change client code */
119 #if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
120 typedef int (GLAPIENTRY *PROC)();
121 typedef unsigned long COLORREF;
125 /* XXX why is this here?
126 * It should probaby be somewhere in src/mesa/drivers/windows/
128 #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
129 # define WGL_FONT_LINES 0
130 # define WGL_FONT_POLYGONS 1
131 #ifndef _GNU_H_WINDOWS32_FUNCTIONS
133 # define wglUseFontBitmaps wglUseFontBitmapsW
134 # define wglUseFontOutlines wglUseFontOutlinesW
136 # define wglUseFontBitmaps wglUseFontBitmapsA
137 # define wglUseFontOutlines wglUseFontOutlinesA
138 # endif /* !UNICODE */
139 #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
140 typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
141 typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
142 typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
143 #if !defined(GLX_USE_MESA)
144 #include <GL/mesa_wgl.h>
147 #endif /* !__MINGW32__ */
151 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
152 * Do not use them unless absolutely necessary!
153 * Try to use a runtime test instead.
154 * For now, only used by some DRI hardware drivers for color/texel packing.
156 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
157 #if defined(__linux__)
158 #include <byteswap.h>
159 #define CPU_TO_LE32( x ) bswap_32( x )
161 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
163 #define MESA_BIG_ENDIAN 1
165 #define CPU_TO_LE32( x ) ( x )
166 #define MESA_LITTLE_ENDIAN 1
168 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
171 #define GL_GLEXT_PROTOTYPES
173 #include "GL/glext.h"
176 #if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
179 #include <GL/internal/glcore.h>
182 /* This is a macro on IRIX */
188 /* Turn off macro checking systems used by other libraries */
194 /* Create a macro so that asm functions can be linked into compilers other
198 #if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
199 #define _ASMAPI __cdecl
203 #ifdef PTR_DECL_IN_FRONT
204 #define _ASMAPIP * _ASMAPI
206 #define _ASMAPIP _ASMAPI *
211 #define _NORMAPI _ASMAPI
212 #define _NORMAPIP _ASMAPIP
219 /* Function inlining */
220 #if defined(__GNUC__)
221 # define INLINE __inline__
222 #elif defined(__MSC__)
223 # define INLINE __inline
224 #elif defined(_MSC_VER)
225 # define INLINE __inline
227 # define INLINE __inline
228 #elif defined(__INTEL_COMPILER)
229 # define INLINE inline
230 #elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
231 # define INLINE __inline
237 /* If we build the library with gcc's -fvisibility=hidden flag, we'll
238 * use the PUBLIC macro to mark functions that are to be exported.
240 * We also need to define a USED attribute, so the optimizer doesn't
241 * inline a static function that we later use in an alias. - ajax
243 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
244 # define PUBLIC __attribute__((visibility("default")))
245 # define USED __attribute__((used))
252 /* Some compilers don't like some of Mesa's const usage */
260 #if defined(BUILD_FOR_SNAP) && defined(CHECKED)
261 # define ASSERT(X) _CHECK(X)
263 # define ASSERT(X) assert(X)
269 #if !defined __GNUC__ || __GNUC__ < 3
270 # define __builtin_expect(x, y) x
275 /* XXX these are temporary here! */
276 #define GL_FRAMEBUFFER_EXT 0x8D40
277 #define GL_RENDERBUFFER_EXT 0x8D41
278 #define GL_STENCIL_INDEX_EXT 0x8D45
279 #define GL_STENCIL_INDEX1_EXT 0x8D46
280 #define GL_STENCIL_INDEX4_EXT 0x8D47
281 #define GL_STENCIL_INDEX8_EXT 0x8D48
282 #define GL_STENCIL_INDEX16_EXT 0x8D49
283 #define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
284 #define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
285 #define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
286 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
287 #define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
288 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
289 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
290 #define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
291 #define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
292 #define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
293 #define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
294 #define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
295 #define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
296 #define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
297 #define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
298 #define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
299 #define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
300 #define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
301 #define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
302 #define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
303 #define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
304 #define GL_COLOR_ATTACHMENT13_EXT 0x8CED
305 #define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
306 #define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
307 #define GL_DEPTH_ATTACHMENT_EXT 0x8D00
308 #define GL_STENCIL_ATTACHMENT_EXT 0x8D20
309 #define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
310 #define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
311 #define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
312 #define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
313 #define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
314 #define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
315 #define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
316 #define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
317 #define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
318 #define GL_FRAMEBUFFER_STATUS_ERROR_EXT 0x8CDE
319 #define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
320 #define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
321 #define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
322 #define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
323 #define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
328 #endif /* GLHEADER_H */