Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
5.8 KiB

  1. #ifndef __glglobal_h_
  2. #define __glglobal_h_
  3. /*
  4. ** Copyright 1991, 1992, 1993, Silicon Graphics, Inc.
  5. ** All Rights Reserved.
  6. **
  7. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ** the contents of this file may not be disclosed to third parties, copied or
  9. ** duplicated in any form, in whole or in part, without the prior written
  10. ** permission of Silicon Graphics, Inc.
  11. **
  12. ** RESTRICTED RIGHTS LEGEND:
  13. ** Use, duplication or disclosure by the Government is subject to restrictions
  14. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ** rights reserved under the Copyright Laws of the United States.
  18. */
  19. #include "context.h"
  20. /*
  21. ** Some misc constants
  22. */
  23. #ifdef NT
  24. // These constants can either be static memory constants or
  25. // real constants. This #if should be modified for each
  26. // platform to optimize the constant type for the platform
  27. // For example, the x86 FPU can only load from memory so having
  28. // these constants as memory locations rather than values is
  29. // a clear win
  30. #if defined(_X86_) || defined(_ALPHA_) || defined(_MIPS_) || defined(_PPC_)
  31. extern const double __glDoubleTwo;
  32. extern const double __glDoubleMinusTwo;
  33. #ifdef _ALPHA_
  34. // On Alpha, register f31 always reads as zero.
  35. #define __glZero ((__GLfloat) 0.0)
  36. #else
  37. extern const __GLfloat __glZero;
  38. #endif
  39. extern const __GLfloat __glOne;
  40. extern const __GLfloat __glMinusOne;
  41. extern const __GLfloat __glHalf;
  42. extern const __GLfloat __glDegreesToRadians;
  43. extern const __GLfloat __glPi;
  44. extern const __GLfloat __glSqrt2;
  45. extern const __GLfloat __glE;
  46. extern const __GLfloat __glVal128;
  47. extern const __GLfloat __glVal255;
  48. extern const __GLfloat __glOneOver255;
  49. extern const __GLfloat __glVal256;
  50. extern const __GLfloat __glOneOver512;
  51. extern const __GLfloat __glVal768;
  52. extern const __GLfloat __glVal65535;
  53. extern const __GLfloat __glVal65536;
  54. extern const __GLfloat __glOneOver65535;
  55. extern const __GLfloat __glTexSubDiv;
  56. extern const __GLfloat __glVal2147483648;
  57. /*
  58. ** Not quite 2^31-1 because of possible floating point errors. 4294965000
  59. ** is a much safer number to use.
  60. */
  61. extern const __GLfloat __glVal4294965000;
  62. extern const __GLfloat __glOneOver4294965000;
  63. #else // Real values
  64. #define __glDoubleTwo ((double) 2.0)
  65. #define __glDoubleMinusTwo ((double) -2.0)
  66. #define __glZero ((__GLfloat) 0.0)
  67. #define __glOne ((__GLfloat) 1.0)
  68. #define __glMinusOne ((__GLfloat) -1.0)
  69. #define __glHalf ((__GLfloat) 0.5)
  70. #define __glDegreesToRadians (__glPi / (__GLfloat) 180.0)
  71. #define __glPi ((__GLfloat) 3.14159265358979323846)
  72. #define __glSqrt2 ((__GLfloat) 1.41421356237309504880)
  73. #define __glE ((__GLfloat) 2.7182818284590452354)
  74. #define __glVal128 ((__GLfloat) 128.0)
  75. #define __glVal255 ((__GLfloat) 255.0)
  76. #define __glOneOver255 ((__GLfloat) (1.0 / 255.0))
  77. #define __glVal256 ((__GLfloat) 256.0)
  78. #define __glOneOver512 ((__GLfloat) (1.0 / 512.0))
  79. #define __glVal768 ((__GLfloat) 768.0)
  80. #define __glVal65535 ((__GLfloat) 65535.0)
  81. #define __glVal65536 ((__GLfloat) 65536.0)
  82. #define __glOneOver65535 ((__GLfloat) (1.0 / 65535.0))
  83. #define __glVal2147483648 ((__GLfloat) 2147483648.0)
  84. /*
  85. ** Not quite 2^31-1 because of possible floating point errors. 4294965000
  86. ** is a much safer number to use.
  87. */
  88. #define __glVal4294965000 ((__GLfloat) (4294965000.0))
  89. #define __glOneOver4294965000 ((__GLfloat) (1.0 / 4294965000.0))
  90. #endif // Real values
  91. #else
  92. #define __glZero ((__GLfloat) 0.0)
  93. #define __glOne (gc->constants.one)
  94. #define __glMinusOne ((__GLfloat) -1.0)
  95. #define __glHalf (gc->constants.half)
  96. #define __glTwo ((__GLfloat) 2.0)
  97. #define __glDegreesToRadians (__glPi / (__GLfloat) 180.0)
  98. #define __glPi ((__GLfloat) 3.14159265358979323846)
  99. #define __glSqrt2 ((__GLfloat) 1.41421356237309504880)
  100. #define __glE ((__GLfloat) 2.7182818284590452354)
  101. #define __glVal255 ((__GLfloat) 255.0)
  102. #define __glOneOver255 ((__GLfloat) (1.0 / 255.0))
  103. #define __glVal65535 ((__GLfloat) 65535.0)
  104. #define __glOneOver65535 ((__GLfloat) (1.0 / 65535.0))
  105. /*
  106. ** Not quite 2^31-1 because of possible floating point errors. 4294965000
  107. ** is a much safer number to use.
  108. */
  109. #define __glVal4294965000 ((__GLfloat) (4294965000.0))
  110. #define __glOneOver4294965000 ((__GLfloat) (1.0 / 4294965000.0))
  111. #endif // NT
  112. // This is used by the macro __GL_UB_TO_FLOAT which converts
  113. // unsigned bytes to floats in the range [0,1].
  114. extern GLfloat __glUByteToFloat[256];
  115. // This is used by the macro __GL_B_TO_FLOAT for byte to float component
  116. // conversion.
  117. extern GLfloat __glByteToFloat[256];
  118. // This is used by frustum clipping to determine which plane coordinate
  119. // to use
  120. extern GLuint __glFrustumOffsets[];
  121. /************************************************************************/
  122. #define __GL_SETUP() \
  123. __GLcontext *gc = GLTEB_SRVCONTEXT()
  124. #define __GL_IN_BEGIN() \
  125. (gc->beginMode == __GL_IN_BEGIN)
  126. #define __GL_SETUP_NOT_IN_BEGIN() \
  127. __GL_SETUP(); \
  128. if (__GL_IN_BEGIN()) { \
  129. __glSetError(GL_INVALID_OPERATION); \
  130. return; \
  131. }
  132. #define __GL_SETUP_NOT_IN_BEGIN_VALIDATE() \
  133. __GL_SETUP(); \
  134. __GLbeginMode beginMode = gc->beginMode; \
  135. if (beginMode != __GL_NOT_IN_BEGIN) { \
  136. if (beginMode == __GL_NEED_VALIDATE) { \
  137. (*gc->procs.validate)(gc); \
  138. gc->beginMode = __GL_NOT_IN_BEGIN; \
  139. } else { \
  140. __glSetError(GL_INVALID_OPERATION); \
  141. return; \
  142. } \
  143. }
  144. #define __GL_SETUP_NOT_IN_BEGIN2() \
  145. __GL_SETUP(); \
  146. if (__GL_IN_BEGIN()) { \
  147. __glSetError(GL_INVALID_OPERATION); \
  148. return 0; \
  149. }
  150. #endif /* __glglobal_h_ */