home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mesa5.zip / mesa5src.zip / glheader.h < prev    next >
Text File  |  2002-12-14  |  9KB  |  308 lines

  1. /* $Id: glheader.h,v 1.29 2002/10/30 19:44:41 brianp Exp $ */
  2.  
  3. /*
  4.  * Mesa 3-D graphics library
  5.  * Version:  5.0
  6.  *
  7.  * Copyright (C) 1999-2002  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. #if defined(XFree86LOADER) && defined(IN_MODULE)
  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. #include <stdarg.h>
  70.  
  71.  
  72. #ifdef HAVE_CONFIG_H
  73. #include "conf.h"
  74. #endif
  75.  
  76.  
  77. #if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
  78. #      define __WIN32__
  79. #      define finite _finite
  80. #endif
  81. #if defined(__IBMC__) || defined(__IBMCPP__)
  82.     #define USE_IEEE
  83.     #include "GL/os2_config.h"
  84.  
  85. #elif !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
  86. #  pragma warning( disable : 4068 ) /* unknown pragma */
  87. #  pragma warning( disable : 4710 ) /* function 'foo' not inlined */
  88. #  pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */
  89. #  pragma warning( disable : 4127 ) /* conditional expression is constant */
  90. #  if defined(MESA_MINWARN)
  91. #    pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */
  92. #    pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */
  93. #    pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */
  94. #    pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */
  95. #    pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
  96. #  endif
  97. #  if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
  98. #    define GLAPI __declspec(dllexport)
  99. #    define WGLAPI __declspec(dllexport)
  100. #  elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
  101. #    define GLAPI __declspec(dllimport)
  102. #    define WGLAPI __declspec(dllimport)
  103. #  else /* for use with static link lib build of Win32 edition only */
  104. #    define GLAPI extern
  105. #    define WGLAPI __declspec(dllimport)
  106. #  endif /* _STATIC_MESA support */
  107. #  define GLAPIENTRY __stdcall
  108. #  define GLAPIENTRYP __stdcall *
  109. #  define GLCALLBACK __stdcall
  110. #  define GLCALLBACKP __stdcall *
  111. #  if defined(__CYGWIN__)
  112. #    define GLCALLBACKPCAST *
  113. #  else
  114. #    define GLCALLBACKPCAST __stdcall *
  115. #  endif
  116. #  define GLWINAPI __stdcall
  117. #  define GLWINAPIV __cdecl
  118. #else
  119. /* non-Windows compilation */
  120. #  define GLAPI extern
  121. #  define GLAPIENTRY
  122. #  define GLAPIENTRYP *
  123. #  define GLCALLBACK
  124. #  define GLCALLBACKP *
  125. #  define GLCALLBACKPCAST *
  126. #  define GLWINAPI
  127. #  define GLWINAPIV
  128. #endif /* WIN32 / CYGWIN bracket */
  129.  
  130. /* compatability guard so we don't need to change client code */
  131.  
  132. #if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) && !defined(__CYGWIN__)
  133. #if 0
  134. #      define CALLBACK GLCALLBACK
  135. typedef void *HGLRC;
  136. typedef void *HDC;
  137. #endif
  138. typedef int (GLAPIENTRY *PROC)();
  139. typedef unsigned long COLORREF;
  140. #endif
  141.  
  142.  
  143. /* Make sure we include glext.h from gl.h */
  144. #define GL_GLEXT_PROTOTYPES
  145.  
  146.  
  147. #if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
  148. #      define WGL_FONT_LINES      0
  149. #      define WGL_FONT_POLYGONS   1
  150. #ifndef _GNU_H_WINDOWS32_FUNCTIONS
  151. #      ifdef UNICODE
  152. #              define wglUseFontBitmaps  wglUseFontBitmapsW
  153. #              define wglUseFontOutlines  wglUseFontOutlinesW
  154. #      else
  155. #              define wglUseFontBitmaps  wglUseFontBitmapsA
  156. #              define wglUseFontOutlines  wglUseFontOutlinesA
  157. #      endif /* !UNICODE */
  158. #endif /* _GNU_H_WINDOWS32_FUNCTIONS */
  159. typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR;
  160. typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT;
  161. typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
  162. #if !defined(GLX_USE_MESA)
  163. #include <gl/mesa_wgl.h>
  164. #endif
  165. #endif
  166.  
  167.  
  168. /*
  169.  * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
  170.  * Do not use them unless absolutely necessary!
  171.  * Try to use a runtime test instead.
  172.  * For now, only used by some DRI hardware drivers for color/texel packing.
  173.  */
  174. #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
  175. #if defined(__linux__)
  176. #include <byteswap.h>
  177. #define CPU_TO_LE32( x )       bswap_32( x )
  178. #else /*__linux__*/
  179. #define CPU_TO_LE32( x )       ( x )  /* fix me for non-Linux big-endian! */
  180. #endif /*__linux__*/
  181. #define MESA_BIG_ENDIAN 1
  182. #else
  183. #define CPU_TO_LE32( x )       ( x )
  184. #define MESA_LITTLE_ENDIAN 1
  185. #endif
  186. #define LE32_TO_CPU( x )       CPU_TO_LE32( x )
  187.  
  188.  
  189. /* This is a macro on IRIX */
  190. #ifdef _P
  191. #undef _P
  192. #endif
  193.  
  194.  
  195.  
  196. #include "GL/gl.h"
  197. #include "GL/glext.h"
  198.  
  199.  
  200. #ifndef CAPI
  201. #ifdef WIN32
  202. #define CAPI _cdecl
  203. #else
  204. #define CAPI
  205. #endif
  206. #endif
  207. #include <GL/internal/glcore.h>
  208.  
  209.  
  210.  
  211. /* Disable unreachable code warnings for Watcom C++ */
  212. #ifdef __WATCOMC__
  213. #pragma disable_message(201)
  214. #endif
  215.  
  216.  
  217. /* Turn off macro checking systems used by other libraries */
  218. #ifdef CHECK
  219. #undef CHECK
  220. #endif
  221.  
  222.  
  223. /* Create a macro so that asm functions can be linked into compilers other
  224.  * than GNU C
  225.  */
  226. #ifndef _ASMAPI
  227. #if !defined( __GNUC__ ) && !defined( VMS )
  228. #define _ASMAPI __cdecl
  229. #else
  230. #define _ASMAPI
  231. #endif
  232. #ifdef PTR_DECL_IN_FRONT
  233. #define        _ASMAPIP * _ASMAPI
  234. #else
  235. #define        _ASMAPIP _ASMAPI *
  236. #endif
  237. #endif
  238.  
  239. #ifdef USE_X86_ASM
  240. #define _NORMAPI _ASMAPI
  241. #define _NORMAPIP _ASMAPIP
  242. #else
  243. #define _NORMAPI
  244. #define _NORMAPIP *
  245. #endif
  246.  
  247.  
  248. /* Function inlining */
  249. #if defined(__GNUC__)
  250. #  define INLINE __inline__
  251. #elif defined(__MSC__)
  252. #  define INLINE __inline
  253. #elif defined(_MSC_VER)
  254. #  define INLINE __inline
  255. #elif defined(__ICL)
  256. #  define INLINE __inline
  257.  
  258. #elif (defined(__IBMC__) || defined(__IBMCPP__))
  259.   #if __cplusplus
  260.     #define INLINE inline
  261.   #else
  262.     #define INLINE _Inline
  263.   #endif
  264. #else
  265.  
  266. #  define INLINE
  267. #endif
  268.  
  269.  
  270. /*
  271.  * Provide a reasonable replacement for __FUNCTION__ when using
  272.  * non-GNU C compilers.
  273.  */
  274. #if !defined(__GNUC__) && !defined(__IBMCPP__) && !defined(__IBMC__)
  275. #define STRINGIZE(x) #x
  276. #define STRINGIZE_EVAL(x) STRINGIZE(x)
  277. #define __FUNCTION__ STRINGIZE_EVAL(__FILE__) ", line " STRINGIZE_EVAL(__LINE__)
  278. #endif
  279.  
  280.  
  281. /* Some compilers don't like some of Mesa's const usage */
  282. #ifdef NO_CONST
  283. #  define CONST
  284. #else
  285. #  define CONST const
  286. #endif
  287.  
  288.  
  289. #ifdef DEBUG
  290. #  define ASSERT(X)   assert(X)
  291. #else
  292. #  define ASSERT(X)
  293. #endif
  294.  
  295.  
  296. /*
  297.  * Sometimes we treat GLfloats as GLints.  On x86 systems, moving a float
  298.  * as a int (thereby using integer registers instead of fp registers) is
  299.  * a performance win.  Typically, this can be done with ordinary casts.
  300.  * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
  301.  * these casts generate warnings.
  302.  * The following union typedef is used to solve that.
  303.  */
  304. typedef union { GLfloat f; GLint i; } fi_type;
  305.  
  306.  
  307. #endif /* GLHEADER_H */
  308.