platformGL.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _PLATFORMGL_H_
  23. #define _PLATFORMGL_H_
  24. #define MIN_RESOLUTION_X 320
  25. #define MIN_RESOLUTION_Y 320
  26. #define MIN_RESOLUTION_BIT_DEPTH 32
  27. #define MIN_RESOLUTION_XY_STRING "320 320"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #define GLAPI extern
  32. #define GLAPIENTRY
  33. #include "platformX86UNIX/gl_types.h"
  34. #define GL_FUNCTION(fn_return,fn_name,fn_args,fn_value) extern fn_return (*fn_name)fn_args;
  35. #include "platform/GLCoreFunc.h"
  36. #include "platform/GLExtFunc.h"
  37. #undef GL_FUNCTION
  38. // GLU functions are linked at compile time, except in the dedicated server build
  39. #ifndef DEDICATED
  40. #define GL_FUNCTION(fn_return,fn_name,fn_args,fn_value) fn_return fn_name fn_args;
  41. #else
  42. #define GL_FUNCTION(fn_return,fn_name,fn_args,fn_value) extern fn_return (*fn_name)fn_args;
  43. #endif
  44. #include "platform/GLUFunc.h"
  45. #undef GL_FUNCTION
  46. namespace GLLoader
  47. {
  48. bool OpenGLInit();
  49. void OpenGLShutdown();
  50. bool OpenGLDLLInit();
  51. void OpenGLDLLShutdown();
  52. }
  53. /*
  54. * GL state information.
  55. */
  56. struct GLState
  57. {
  58. bool suppARBMultitexture;
  59. bool suppEXTblendcolor;
  60. bool suppEXTblendminmax;
  61. bool suppPackedPixels;
  62. bool suppTexEnvAdd;
  63. bool suppLockedArrays;
  64. bool suppTextureEnvCombine;
  65. bool suppVertexArrayRange;
  66. bool suppFogCoord;
  67. bool suppEdgeClamp;
  68. bool suppTextureCompression;
  69. bool suppS3TC;
  70. bool suppFXT1;
  71. bool suppTexAnisotropic;
  72. bool suppPalettedTexture;
  73. bool suppVertexBuffer;
  74. bool suppSwapInterval;
  75. unsigned int triCount[4];
  76. unsigned int primCount[4];
  77. unsigned int primMode; // 0-3
  78. GLfloat maxAnisotropy;
  79. GLint maxTextureUnits;
  80. };
  81. extern GLState gGLState;
  82. extern bool gOpenGLDisablePT;
  83. extern bool gOpenGLDisableCVA;
  84. extern bool gOpenGLDisableTEC;
  85. extern bool gOpenGLDisableARBMT;
  86. extern bool gOpenGLDisableFC;
  87. extern bool gOpenGLDisableTCompress;
  88. extern bool gOpenGLNoEnvColor;
  89. extern float gOpenGLGammaCorrection;
  90. extern bool gOpenGLNoDrawArraysAlpha;
  91. inline void dglSetRenderPrimType(unsigned int type)
  92. {
  93. gGLState.primMode = type;
  94. }
  95. inline void dglClearPrimMetrics()
  96. {
  97. for(int i = 0; i < 4; i++)
  98. gGLState.triCount[i] = gGLState.primCount[i] = 0;
  99. }
  100. inline bool dglDoesSupportPalettedTexture()
  101. {
  102. return gGLState.suppPalettedTexture && (gOpenGLDisablePT == false);
  103. }
  104. inline bool dglDoesSupportCompiledVertexArray()
  105. {
  106. return gGLState.suppLockedArrays && (gOpenGLDisableCVA == false);
  107. }
  108. inline bool dglDoesSupportTextureEnvCombine()
  109. {
  110. return gGLState.suppTextureEnvCombine && (gOpenGLDisableTEC == false);
  111. }
  112. inline bool dglDoesSupportARBMultitexture()
  113. {
  114. return gGLState.suppARBMultitexture && (gOpenGLDisableARBMT == false);
  115. }
  116. inline bool dglDoesSupportEXTBlendColor()
  117. {
  118. return gGLState.suppEXTblendcolor;
  119. }
  120. inline bool dglDoesSupportEXTBlendMinMax()
  121. {
  122. return gGLState.suppEXTblendminmax;
  123. }
  124. inline bool dglDoesSupportVertexArrayRange()
  125. {
  126. return gGLState.suppVertexArrayRange;
  127. }
  128. inline bool dglDoesSupportFogCoord()
  129. {
  130. return gGLState.suppFogCoord && (gOpenGLDisableFC == false);
  131. }
  132. inline bool dglDoesSupportEdgeClamp()
  133. {
  134. return gGLState.suppEdgeClamp;
  135. }
  136. inline bool dglDoesSupportTextureCompression()
  137. {
  138. return gGLState.suppTextureCompression && (gOpenGLDisableTCompress == false);
  139. }
  140. inline bool dglDoesSupportS3TC()
  141. {
  142. return gGLState.suppS3TC;
  143. }
  144. inline bool dglDoesSupportFXT1()
  145. {
  146. return gGLState.suppFXT1;
  147. }
  148. inline bool dglDoesSupportTexEnvAdd()
  149. {
  150. return gGLState.suppTexEnvAdd;
  151. }
  152. inline bool dglDoesSupportTexAnisotropy()
  153. {
  154. return gGLState.suppTexAnisotropic;
  155. }
  156. inline bool dglDoesSupportVertexBuffer()
  157. {
  158. return gGLState.suppVertexBuffer;
  159. }
  160. inline GLfloat dglGetMaxAnisotropy()
  161. {
  162. return gGLState.maxAnisotropy;
  163. }
  164. inline GLint dglGetMaxTextureUnits()
  165. {
  166. if (dglDoesSupportARBMultitexture())
  167. return gGLState.maxTextureUnits;
  168. else
  169. return 1;
  170. }
  171. #ifdef __cplusplus
  172. }
  173. #endif
  174. #endif