glheader.h revision 489ccef3982267b0d35c8548921f58d553c25a3a
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:  6.3
24 *
25 * Copyright (C) 1999-2004  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/* This is no longer uses since we dumped autoconf/automake! */
74#ifdef HAVE_CONFIG_H
75#include "conf.h"
76#endif
77
78
79#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
80#  define __WIN32__
81#  define finite _finite
82#endif
83
84#if defined(__WATCOMC__)
85#  define finite _finite
86#  pragma disable_message(201) /* Disable unreachable code warnings */
87#endif
88
89
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 */
102#    endif
103#  endif
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 */
112
113
114#ifndef __MINGW32__
115/* XXX why is this here?
116 * It should probaby be somewhere in src/mesa/drivers/windows/
117 */
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)
120typedef int (GLAPIENTRY *PROC)();
121typedef unsigned long COLORREF;
122#endif
123
124
125/* XXX why is this here?
126 * It should probaby be somewhere in src/mesa/drivers/windows/
127 */
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
132#	ifdef UNICODE
133#		define wglUseFontBitmaps  wglUseFontBitmapsW
134#		define wglUseFontOutlines  wglUseFontOutlinesW
135#	else
136#		define wglUseFontBitmaps  wglUseFontBitmapsA
137#		define wglUseFontOutlines  wglUseFontOutlinesA
138#	endif /* !UNICODE */
139#endif /* _GNU_H_WINDOWS32_FUNCTIONS */
140typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
141typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
142typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
143#if !defined(GLX_USE_MESA)
144#include <GL/mesa_wgl.h>
145#endif
146#endif
147#endif /* !__MINGW32__ */
148
149
150/*
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.
155 */
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 )
160#else /*__linux__*/
161#define CPU_TO_LE32( x )	( x )  /* fix me for non-Linux big-endian! */
162#endif /*__linux__*/
163#define MESA_BIG_ENDIAN 1
164#else
165#define CPU_TO_LE32( x )	( x )
166#define MESA_LITTLE_ENDIAN 1
167#endif
168#define LE32_TO_CPU( x )	CPU_TO_LE32( x )
169
170
171#define GL_GLEXT_PROTOTYPES
172#include "GL/gl.h"
173#include "GL/glext.h"
174
175
176#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
177#define CAPI _cdecl
178#endif
179#include <GL/internal/glcore.h>
180
181
182/* XXX temporary hack - remove when glext.h is updated */
183#ifndef GL_ARB_half_float_pixel
184#define GL_ARB_half_float_pixel 1
185#define GL_HALF_FLOAT_ARB 0x140B
186typedef GLushort GLhalfARB;
187#endif
188
189/* XXX temporary hack - remove when glext.h is updated */
190#ifndef GL_ARB_texture_float
191#define GL_ARB_texture_float 1
192#define GL_TEXTURE_RED_TYPE_ARB             0x9000
193#define GL_TEXTURE_GREEN_TYPE_ARB           0x9001
194#define GL_TEXTURE_BLUE_TYPE_ARB            0x9002
195#define GL_TEXTURE_ALPHA_TYPE_ARB           0x9003
196#define GL_TEXTURE_LUMINANCE_TYPE_ARB       0x9004
197#define GL_TEXTURE_INTENSITY_TYPE_ARB       0x9005
198#define GL_TEXTURE_DEPTH_TYPE_ARB           0x9006
199#define GL_UNSIGNED_NORMALIZED_ARB          0x9007
200#define GL_RGBA32F_ARB                      0x8814
201#define GL_RGB32F_ARB                       0x8815
202#define GL_ALPHA32F_ARB                     0x8816
203#define GL_INTENSITY32F_ARB                 0x8817
204#define GL_LUMINANCE32F_ARB                 0x8818
205#define GL_LUMINANCE_ALPHA32F_ARB           0x8819
206#define GL_RGBA16F_ARB                      0x881A
207#define GL_RGB16F_ARB                       0x881B
208#define GL_ALPHA16F_ARB                     0x881C
209#define GL_INTENSITY16F_ARB                 0x881D
210#define GL_LUMINANCE16F_ARB                 0x881E
211#define GL_LUMINANCE_ALPHA16F_ARB           0x881F
212#endif
213
214/* XXX temporary hack - remove when glext.h is updated */
215#ifndef GL_CURRENT_PROGRAM
216#define GL_CURRENT_PROGRAM		0x8B8D
217#define GL_POINT_SPRITE_COORD_ORIGIN	0x8CA0
218#define GL_LOWER_LEFT			0x8CA1
219#define GL_UPPER_LEFT			0x8CA2
220#define GL_STENCIL_BACK_REF		0x8CA3
221#define GL_STENCIL_BACK_VALUE_MASK	0x8CA4
222#define GL_STENCIL_BACK_WRITEMASK	0x8CA5
223#endif
224
225
226
227/* This is a macro on IRIX */
228#ifdef _P
229#undef _P
230#endif
231
232
233/* Turn off macro checking systems used by other libraries */
234#ifdef CHECK
235#undef CHECK
236#endif
237
238
239/* Create a macro so that asm functions can be linked into compilers other
240 * than GNU C
241 */
242#ifndef _ASMAPI
243#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
244#define _ASMAPI __cdecl
245#else
246#define _ASMAPI
247#endif
248#ifdef	PTR_DECL_IN_FRONT
249#define	_ASMAPIP * _ASMAPI
250#else
251#define	_ASMAPIP _ASMAPI *
252#endif
253#endif
254
255#ifdef USE_X86_ASM
256#define _NORMAPI _ASMAPI
257#define _NORMAPIP _ASMAPIP
258#else
259#define _NORMAPI
260#define _NORMAPIP *
261#endif
262
263
264/* Function inlining */
265#if defined(__GNUC__)
266#  define INLINE __inline__
267#elif defined(__MSC__)
268#  define INLINE __inline
269#elif defined(_MSC_VER)
270#  define INLINE __inline
271#elif defined(__ICL)
272#  define INLINE __inline
273#elif defined(__INTEL_COMPILER)
274#  define INLINE inline
275#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
276#  define INLINE __inline
277#else
278#  define INLINE
279#endif
280
281
282/* If we build the library with gcc's -fvisibility=hidden flag, we'll
283 * use the PUBLIC macro to mark functions that are to be exported.
284 *
285 * We also need to define a USED attribute, so the optimizer doesn't
286 * inline a static function that we later use in an alias. - ajax
287 */
288#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
289#  define PUBLIC __attribute__((visibility("default")))
290#  define USED __attribute__((used))
291#else
292#  define PUBLIC
293#  define USED
294#endif
295
296
297/* Some compilers don't like some of Mesa's const usage */
298#ifdef NO_CONST
299#  define CONST
300#else
301#  define CONST const
302#endif
303
304
305#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
306#  define ASSERT(X)   _CHECK(X)
307#elif defined(DEBUG)
308#  define ASSERT(X)   assert(X)
309#else
310#  define ASSERT(X)
311#endif
312
313
314#if !defined __GNUC__ || __GNUC__ < 3
315#  define __builtin_expect(x, y) x
316#endif
317
318
319#include "config.h"
320
321#endif /* GLHEADER_H */
322