Added most of the infrastructure required to support
[mesa.git] / src / mesa / main / glheader.h
1 /**
2 * \file glheader.h
3 * Top-most include file.
4 *
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.
10 *
11 * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
12 *
13 * If you touch this file, everything gets recompiled!
14 *
15 * This file should be included before any other header in the .c files.
16 *
17 * Put compiler/OS/assembly pragmas and macros here to avoid
18 * cluttering other source files.
19 */
20
21 /*
22 * Mesa 3-D graphics library
23 * Version: 5.1
24 *
25 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
26 *
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:
33 *
34 * The above copyright notice and this permission notice shall be included
35 * in all copies or substantial portions of the Software.
36 *
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.
43 */
44
45
46 #ifndef GLHEADER_H
47 #define GLHEADER_H
48
49
50 #if defined(XFree86LOADER) && defined(IN_MODULE)
51 #include "xf86_ansic.h"
52 #else
53 #include <assert.h>
54 #include <ctype.h>
55 /* If we can use Compaq's Fast Math Library on Alpha */
56 #if defined(__alpha__) && defined(CCPML)
57 #include <cpml.h>
58 #else
59 #include <math.h>
60 #endif
61 #include <limits.h>
62 #include <stdlib.h>
63 #include <stdio.h>
64 #include <string.h>
65 #if defined(__linux__) && defined(__i386__)
66 #include <fpu_control.h>
67 #endif
68 #endif
69 #include <float.h>
70 #include <stdarg.h>
71
72
73 #ifdef HAVE_CONFIG_H
74 #include "conf.h"
75 #endif
76
77
78 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
79 # define __WIN32__
80 # define finite _finite
81 #endif
82
83 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
84 # pragma warning( disable : 4068 ) /* unknown pragma */
85 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
86 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
87 # pragma warning( disable : 4127 ) /* conditional expression is constant */
88 # if defined(MESA_MINWARN)
89 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
90 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
91 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
92 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
93 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
94 # endif
95 # if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
96 # define GLAPI __declspec(dllexport)
97 # define WGLAPI __declspec(dllexport)
98 # elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
99 # define GLAPI __declspec(dllimport)
100 # define WGLAPI __declspec(dllimport)
101 # else /* for use with static link lib build of Win32 edition only */
102 # define GLAPI extern
103 # define WGLAPI __declspec(dllimport)
104 # endif /* _STATIC_MESA support */
105 # define GLAPIENTRY __stdcall
106 # define GLAPIENTRYP __stdcall *
107 # define GLCALLBACK __stdcall
108 # define GLCALLBACKP __stdcall *
109 # if defined(__CYGWIN__)
110 # define GLCALLBACKPCAST *
111 # else
112 # define GLCALLBACKPCAST __stdcall *
113 # endif
114 # define GLWINAPI __stdcall
115 # define GLWINAPIV __cdecl
116 #else
117 /* non-Windows compilation */
118 # define GLAPI extern
119 # define GLAPIENTRY
120 # define GLAPIENTRYP *
121 # define GLCALLBACK
122 # define GLCALLBACKP *
123 # define GLCALLBACKPCAST *
124 # define GLWINAPI
125 # define GLWINAPIV
126 #endif /* WIN32 / CYGWIN bracket */
127
128 /* compatibility guard so we don't need to change client code */
129
130 #if defined(_WIN32) && !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__)
131 #if 0
132 # define CALLBACK GLCALLBACK
133 typedef void *HGLRC;
134 typedef void *HDC;
135 #endif
136 typedef int (GLAPIENTRY *PROC)();
137 typedef unsigned long COLORREF;
138 #endif
139
140
141 /* Make sure we include glext.h from gl.h */
142 #define GL_GLEXT_PROTOTYPES
143
144
145 #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
146 # define WGL_FONT_LINES 0
147 # define WGL_FONT_POLYGONS 1
148 #ifndef _GNU_H_WINDOWS32_FUNCTIONS
149 # ifdef UNICODE
150 # define wglUseFontBitmaps wglUseFontBitmapsW
151 # define wglUseFontOutlines wglUseFontOutlinesW
152 # else
153 # define wglUseFontBitmaps wglUseFontBitmapsA
154 # define wglUseFontOutlines wglUseFontOutlinesA
155 # endif /* !UNICODE */
156 #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
157 typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
158 typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
159 typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
160 #if !defined(GLX_USE_MESA)
161 #include <gl/mesa_wgl.h>
162 #endif
163 #endif
164
165
166 /*
167 * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
168 * Do not use them unless absolutely necessary!
169 * Try to use a runtime test instead.
170 * For now, only used by some DRI hardware drivers for color/texel packing.
171 */
172 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
173 #if defined(__linux__)
174 #include <byteswap.h>
175 #define CPU_TO_LE32( x ) bswap_32( x )
176 #else /*__linux__*/
177 #define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
178 #endif /*__linux__*/
179 #define MESA_BIG_ENDIAN 1
180 #else
181 #define CPU_TO_LE32( x ) ( x )
182 #define MESA_LITTLE_ENDIAN 1
183 #endif
184 #define LE32_TO_CPU( x ) CPU_TO_LE32( x )
185
186
187 /* This is a macro on IRIX */
188 #ifdef _P
189 #undef _P
190 #endif
191
192
193
194 #include "GL/gl.h"
195 #include "GL/glext.h"
196
197
198 #ifndef CAPI
199 #ifdef WIN32
200 #define CAPI _cdecl
201 #else
202 #define CAPI
203 #endif
204 #endif
205 #include <GL/internal/glcore.h>
206
207
208
209 /* Disable unreachable code warnings for Watcom C++ */
210 #ifdef __WATCOMC__
211 #pragma disable_message(201)
212 #endif
213
214
215 /* Turn off macro checking systems used by other libraries */
216 #ifdef CHECK
217 #undef CHECK
218 #endif
219
220
221 /* Create a macro so that asm functions can be linked into compilers other
222 * than GNU C
223 */
224 #ifndef _ASMAPI
225 #if !defined( __GNUC__ ) && !defined( VMS )
226 #define _ASMAPI __cdecl
227 #else
228 #define _ASMAPI
229 #endif
230 #ifdef PTR_DECL_IN_FRONT
231 #define _ASMAPIP * _ASMAPI
232 #else
233 #define _ASMAPIP _ASMAPI *
234 #endif
235 #endif
236
237 #ifdef USE_X86_ASM
238 #define _NORMAPI _ASMAPI
239 #define _NORMAPIP _ASMAPIP
240 #else
241 #define _NORMAPI
242 #define _NORMAPIP *
243 #endif
244
245
246 /* Function inlining */
247 #if defined(__GNUC__)
248 # define INLINE __inline__
249 #elif defined(__MSC__)
250 # define INLINE __inline
251 #elif defined(_MSC_VER)
252 # define INLINE __inline
253 #elif defined(__ICL)
254 # define INLINE __inline
255 #else
256 # define INLINE
257 #endif
258
259
260 /*
261 * Provide a reasonable replacement for __FUNCTION__ when using
262 * non-GNU C compilers.
263 */
264 #if !defined(__GNUC__)
265 #define STRINGIZE(x) #x
266 #define STRINGIZE_EVAL(x) STRINGIZE(x)
267 #define __FUNCTION__ STRINGIZE_EVAL(__FILE__) ", line " STRINGIZE_EVAL(__LINE__)
268 #endif
269
270
271 /* Some compilers don't like some of Mesa's const usage */
272 #ifdef NO_CONST
273 # define CONST
274 #else
275 # define CONST const
276 #endif
277
278
279 #ifdef DEBUG
280 # define ASSERT(X) assert(X)
281 #else
282 # define ASSERT(X)
283 #endif
284
285
286 /**
287 * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float
288 * as a int (thereby using integer registers instead of FP registers) is
289 * a performance win. Typically, this can be done with ordinary casts.
290 * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
291 * these casts generate warnings.
292 * The following union typedef is used to solve that.
293 */
294 typedef union { GLfloat f; GLint i; } fi_type;
295
296
297 #include "config.h"
298
299 #endif /* GLHEADER_H */