platformGL.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. //put this here so the GUI can get to it
  25. //<--%PUAP% -Mat add #defines for min window/resolution size
  26. //these can be set as low as 1 1, but we picked 320
  27. //because the iPhone can init to 320x480 or 480x320
  28. #define MIN_RESOLUTION_X 320
  29. #define MIN_RESOLUTION_Y 320//for 320 x 480 or 480 x 320
  30. #define MIN_RESOLUTION_BIT_DEPTH 16
  31. #define MIN_RESOLUTION_XY_STRING "320 320"
  32. //%PUAP%-->
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. #include "platformWin32/gl_types.h"
  37. #define GLAPI extern
  38. #define GLAPIENTRY __stdcall
  39. #include "platformWin32/gl_types.h"
  40. #define GL_FUNCTION(fn_type,fn_name,fn_args, fn_value) extern fn_type (__stdcall *fn_name)fn_args;
  41. #include "platform/GLCoreFunc.h"
  42. #include "platform/GLExtFunc.h"
  43. #include "platform/GLUFunc.h"
  44. #undef GL_FUNCTION
  45. /* EXT_vertex_buffer */
  46. #define GL_V12MTVFMT_EXT 0x8702
  47. #define GL_V12MTNVFMT_EXT 0x8703
  48. #define GL_V12FTVFMT_EXT 0x8704
  49. #define GL_V12FMTVFMT_EXT 0x8705
  50. struct GLState
  51. {
  52. bool suppARBMultitexture;
  53. bool suppEXTblendcolor;
  54. bool suppEXTblendminmax;
  55. bool suppPackedPixels;
  56. bool suppTexEnvAdd;
  57. bool suppLockedArrays;
  58. bool suppTextureEnvCombine;
  59. bool suppVertexArrayRange;
  60. bool suppFogCoord;
  61. bool suppEdgeClamp;
  62. bool suppTextureCompression;
  63. bool suppS3TC;
  64. bool suppFXT1;
  65. bool suppTexAnisotropic;
  66. bool suppPalettedTexture;
  67. bool suppVertexBuffer;
  68. bool suppSwapInterval;
  69. unsigned int triCount[4];
  70. unsigned int primCount[4];
  71. unsigned int primMode; // 0-3
  72. GLfloat maxAnisotropy;
  73. GLint maxTextureUnits;
  74. };
  75. extern GLState gGLState;
  76. #define UNSIGNED_SHORT_5_6_5 0x8363
  77. #define UNSIGNED_SHORT_5_6_5_REV 0x8364
  78. extern bool gOpenGLDisablePT;
  79. extern bool gOpenGLDisableCVA;
  80. extern bool gOpenGLDisableTEC;
  81. extern bool gOpenGLDisableARBMT;
  82. extern bool gOpenGLDisableFC;
  83. extern bool gOpenGLDisableTCompress;
  84. extern bool gOpenGLNoEnvColor;
  85. extern float gOpenGLGammaCorrection;
  86. extern bool gOpenGLNoDrawArraysAlpha;
  87. inline void dglSetRenderPrimType(unsigned int type)
  88. {
  89. gGLState.primMode = type;
  90. }
  91. inline void dglClearPrimMetrics()
  92. {
  93. for(int i = 0; i < 4; i++)
  94. gGLState.triCount[i] = gGLState.primCount[i] = 0;
  95. }
  96. inline bool dglDoesSupportPalettedTexture()
  97. {
  98. return gGLState.suppPalettedTexture && (gOpenGLDisablePT == false);
  99. }
  100. inline bool dglDoesSupportCompiledVertexArray()
  101. {
  102. return gGLState.suppLockedArrays && (gOpenGLDisableCVA == false);
  103. }
  104. inline bool dglDoesSupportTextureEnvCombine()
  105. {
  106. return gGLState.suppTextureEnvCombine && (gOpenGLDisableTEC == false);
  107. }
  108. inline bool dglDoesSupportARBMultitexture()
  109. {
  110. return gGLState.suppARBMultitexture && (gOpenGLDisableARBMT == false);
  111. }
  112. inline bool dglDoesSupportEXTBlendColor()
  113. {
  114. return gGLState.suppEXTblendcolor;
  115. }
  116. inline bool dglDoesSupportEXTBlendMinMax()
  117. {
  118. return gGLState.suppEXTblendminmax;
  119. }
  120. inline bool dglDoesSupportVertexArrayRange()
  121. {
  122. return gGLState.suppVertexArrayRange;
  123. }
  124. inline bool dglDoesSupportFogCoord()
  125. {
  126. return gGLState.suppFogCoord && (gOpenGLDisableFC == false);
  127. }
  128. inline bool dglDoesSupportEdgeClamp()
  129. {
  130. return gGLState.suppEdgeClamp;
  131. }
  132. inline bool dglDoesSupportTextureCompression()
  133. {
  134. return gGLState.suppTextureCompression && (gOpenGLDisableTCompress == false);
  135. }
  136. inline bool dglDoesSupportS3TC()
  137. {
  138. return gGLState.suppS3TC;
  139. }
  140. inline bool dglDoesSupportFXT1()
  141. {
  142. return gGLState.suppFXT1;
  143. }
  144. inline bool dglDoesSupportTexEnvAdd()
  145. {
  146. return gGLState.suppTexEnvAdd;
  147. }
  148. inline bool dglDoesSupportTexAnisotropy()
  149. {
  150. return gGLState.suppTexAnisotropic;
  151. }
  152. inline bool dglDoesSupportVertexBuffer()
  153. {
  154. return gGLState.suppVertexBuffer;
  155. }
  156. inline GLfloat dglGetMaxAnisotropy()
  157. {
  158. return gGLState.maxAnisotropy;
  159. }
  160. inline GLint dglGetMaxTextureUnits()
  161. {
  162. if (dglDoesSupportARBMultitexture())
  163. return gGLState.maxTextureUnits;
  164. else
  165. return 1;
  166. }
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170. #endif