fixed pointer arithmetic error in glCopyPixels
[mesa.git] / src / mesa / main / glheader.h
1 /* $Id: glheader.h,v 1.24 2001/12/20 18:59:39 kschultz Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27
28 #ifndef GLHEADER_H
29 #define GLHEADER_H
30
31
32 /*
33 * This is the top-most include file of the Mesa sources.
34 * It includes gl.h and all system headers which are needed.
35 * Other Mesa source files should _not_ directly include any system
36 * headers. This allows Mesa to be integrated into XFree86 and
37 * allows system-dependent hacks/work-arounds to be collected in one place.
38 *
39 * If you touch this file, everything gets recompiled!
40 *
41 * This file should be included before any other header in the .c files.
42 *
43 * Put compiler/OS/assembly pragmas and macros here to avoid
44 * cluttering other source files.
45 */
46
47
48
49 #ifdef XFree86LOADER
50 #include "xf86_ansic.h"
51 #else
52 #include <assert.h>
53 #include <ctype.h>
54 /* If we can use Compaq's Fast Math Library on Alpha */
55 #if defined(__alpha__) && defined(CCPML)
56 #include <cpml.h>
57 #else
58 #include <math.h>
59 #endif
60 #include <limits.h>
61 #include <stdlib.h>
62 #include <stdio.h>
63 #include <string.h>
64 #if defined(__linux__) && defined(__i386__)
65 #include <fpu_control.h>
66 #endif
67 #endif
68 #include <float.h>
69
70
71 #ifdef HAVE_CONFIG_H
72 #include "conf.h"
73 #endif
74
75
76
77 #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
78 # define __WIN32__
79 # define finite _finite
80 #endif
81
82 #if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
83 # pragma warning( disable : 4068 ) /* unknown pragma */
84 # pragma warning( disable : 4710 ) /* function 'foo' not inlined */
85 # pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
86 # pragma warning( disable : 4127 ) /* conditional expression is constant */
87 # if defined(MESA_MINWARN)
88 # pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
89 # pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
90 # pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
91 # pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
92 # pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
93 # endif
94 # if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
95 # define GLAPI __declspec(dllexport)
96 # define WGLAPI __declspec(dllexport)
97 # elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
98 # define GLAPI __declspec(dllimport)
99 # define WGLAPI __declspec(dllimport)
100 # else /* for use with static link lib build of Win32 edition only */
101 # define GLAPI extern
102 # define WGLAPI __declspec(dllimport)
103 # endif /* _STATIC_MESA support */
104 # define GLAPIENTRY __stdcall
105 # define GLAPIENTRYP __stdcall *
106 # define GLCALLBACK __stdcall
107 # define GLCALLBACKP __stdcall *
108 # if defined(__CYGWIN__)
109 # define GLCALLBACKPCAST *
110 # else
111 # define GLCALLBACKPCAST __stdcall *
112 # endif
113 # define GLWINAPI __stdcall
114 # define GLWINAPIV __cdecl
115 #else
116 /* non-Windows compilation */
117 # define GLAPI extern
118 # define GLAPIENTRY
119 # define GLAPIENTRYP *
120 # define GLCALLBACK
121 # define GLCALLBACKP *
122 # define GLCALLBACKPCAST *
123 # define GLWINAPI
124 # define GLWINAPIV
125 #endif /* WIN32 / CYGWIN bracket */
126
127 /* compatability guard so we don't need to change client code */
128
129 #if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__)
130 #if 0
131 # define CALLBACK GLCALLBACK
132 typedef void *HGLRC;
133 typedef void *HDC;
134 #endif
135 typedef int (GLAPIENTRY *PROC)();
136 typedef unsigned long COLORREF;
137 #endif
138
139
140 /* Make sure we include glext.h from gl.h */
141 #define GL_GLEXT_PROTOTYPES
142
143
144 #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
145 # define WGL_FONT_LINES 0
146 # define WGL_FONT_POLYGONS 1
147 #ifndef _GNU_H_WINDOWS32_FUNCTIONS
148 # ifdef UNICODE
149 # define wglUseFontBitmaps wglUseFontBitmapsW
150 # define wglUseFontOutlines wglUseFontOutlinesW
151 # else
152 # define wglUseFontBitmaps wglUseFontBitmapsA
153 # define wglUseFontOutlines wglUseFontOutlinesA
154 # endif /* !UNICODE */
155 #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
156 typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
157 typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
158 typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
159 #if !defined(GLX_USE_MESA)
160 #include <gl/mesa_wgl.h>
161 #endif
162 #endif
163
164
165 /* This is a macro on IRIX */
166 #ifdef _P
167 #undef _P
168 #endif
169
170
171
172 #include "GL/gl.h"
173 #include "GL/glext.h"
174
175
176 #ifndef CAPI
177 #ifdef WIN32
178 #define CAPI _cdecl
179 #else
180 #define CAPI
181 #endif
182 #endif
183 #include <GL/internal/glcore.h>
184
185
186
187 /* Disable unreachable code warnings for Watcom C++ */
188 #ifdef __WATCOMC__
189 #pragma disable_message(201)
190 #endif
191
192
193 /* Turn off macro checking systems used by other libraries */
194 #ifdef CHECK
195 #undef CHECK
196 #endif
197
198
199 /* Create a macro so that asm functions can be linked into compilers other
200 * than GNU C
201 */
202 #ifndef _ASMAPI
203 #if !defined( __GNUC__ ) && !defined( VMS )
204 #define _ASMAPI __cdecl
205 #else
206 #define _ASMAPI
207 #endif
208 #ifdef PTR_DECL_IN_FRONT
209 #define _ASMAPIP * _ASMAPI
210 #else
211 #define _ASMAPIP _ASMAPI *
212 #endif
213 #endif
214
215 #ifdef USE_X86_ASM
216 #define _NORMAPI _ASMAPI
217 #define _NORMAPIP _ASMAPIP
218 #else
219 #define _NORMAPI
220 #define _NORMAPIP *
221 #endif
222
223
224 /* Function inlining */
225 #if defined(__GNUC__)
226 # define INLINE __inline__
227 #elif defined(__MSC__)
228 # define INLINE __inline
229 #elif defined(_MSC_VER)
230 # define INLINE __inline
231 #elif defined(__ICL)
232 # define INLINE __inline
233 #else
234 # define INLINE
235 #endif
236
237
238 /* Some compilers don't like some of Mesa's const usage */
239 #ifdef NO_CONST
240 # define CONST
241 #else
242 # define CONST const
243 #endif
244
245
246 #ifdef DEBUG
247 # define ASSERT(X) assert(X)
248 #else
249 # define ASSERT(X)
250 #endif
251
252
253 /*
254 * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float
255 * as a int (thereby using integer registers instead of fp registers) is
256 * a performance win. Typically, this can be done with ordinary casts.
257 * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
258 * these casts generate warnings.
259 * The following union typedef is used to solve that.
260 */
261 typedef union { GLfloat f; GLint i; } fi_type;
262
263
264 #ifndef GL_MIRRORED_REPEAT_ARB
265 #define GL_MIRRORED_REPEAT_ARB 0x8370
266 #endif
267 #ifndef GL_ARB_texture_mirrored_repeat
268 #define GL_ARB_texture_mirrored_repeat 1
269 #endif
270
271
272 #endif /* GLHEADER_H */