gfxAPI.cpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 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. #include "gfx/gfxAPI.h"
  23. IMPLEMENT_SCOPE( GFXAPI, GFX,,
  24. "Graphics subystem." );
  25. IMPLEMENT_STRUCT( GFXVideoMode,
  26. GFXVideoMode, GFXAPI,
  27. "Descriptor for a specific video mode." )
  28. FIELD( resolution, resolution, 1, "Width and height of the mode's resolution in pixels." )
  29. FIELD( bitDepth, bitDepth, 1, "Bits per pixel." )
  30. FIELD( refreshRate, refreshRate, 1, "Frequency at which the screen is refreshed (in Hertz)." )
  31. FIELD( fullScreen, fullScreen, 1, "Whether this is a fullscreen or windowed mode." )
  32. FIELD( wideScreen, wideScreen, 1, "Whether this is a widescreen display mode." )
  33. FIELD( antialiasLevel, antialiasLevel, 1, "Maximum or desired antialiasing level." )
  34. END_IMPLEMENT_STRUCT;
  35. ImplementEnumType( GFXAdapterType,
  36. "Back-end graphics API used by the GFX subsystem.\n\n"
  37. "@ingroup GFX" )
  38. { OpenGL, "OpenGL", "OpenGL." },
  39. { Direct3D8, "D3D8", "Direct3D 8." },
  40. { Direct3D9, "D3D9", "Direct3D 9." },
  41. { NullDevice, "NullDevice", "Null device for dedicated servers." },
  42. { Direct3D9_360, "Xenon", "Direct3D 9 on Xbox 360." }
  43. EndImplementEnumType;
  44. ImplementEnumType( GFXBlend,
  45. "The supported blend modes.\n"
  46. "@ingroup GFX" )
  47. { GFXBlendZero, "GFXBlendZero", "(0, 0, 0, 0)" },
  48. { GFXBlendOne, "GFXBlendOne", "(1, 1, 1, 1)" },
  49. { GFXBlendSrcColor, "GFXBlendSrcColor", "(Rs, Gs, Bs, As)" },
  50. { GFXBlendInvSrcColor, "GFXBlendInvSrcColor", "(1 - Rs, 1 - Gs, 1 - Bs, 1 - As)" },
  51. { GFXBlendSrcAlpha, "GFXBlendSrcAlpha", "(As, As, As, As)" },
  52. { GFXBlendInvSrcAlpha, "GFXBlendInvSrcAlpha", "( 1 - As, 1 - As, 1 - As, 1 - As)" },
  53. { GFXBlendDestAlpha, "GFXBlendDestAlpha", "(Ad Ad Ad Ad)" },
  54. { GFXBlendInvDestAlpha, "GFXBlendInvDestAlpha", "(1 - Ad 1 - Ad 1 - Ad 1 - Ad)" },
  55. { GFXBlendDestColor, "GFXBlendDestColor", "(Rd, Gd, Bd, Ad)" },
  56. { GFXBlendInvDestColor, "GFXBlendInvDestColor", "(1 - Rd, 1 - Gd, 1 - Bd, 1 - Ad)" },
  57. { GFXBlendSrcAlphaSat, "GFXBlendSrcAlphaSat", "(f, f, f, 1) where f = min(As, 1 - Ad)" }
  58. EndImplementEnumType;
  59. ImplementEnumType( GFXCmpFunc,
  60. "The supported comparison functions.\n"
  61. "@ingroup GFX" )
  62. { GFXCmpNever, "GFXCmpNever" },
  63. { GFXCmpLess, "GFXCmpLess" },
  64. { GFXCmpEqual, "GFXCmpEqual" },
  65. { GFXCmpLessEqual, "GFXCmpLessEqual" },
  66. { GFXCmpGreater, "GFXCmpGreater" },
  67. { GFXCmpNotEqual, "GFXCmpNotEqual" },
  68. { GFXCmpGreaterEqual, "GFXCmpGreaterEqual" },
  69. { GFXCmpAlways, "GFXCmpAlways" },
  70. EndImplementEnumType;
  71. ImplementEnumType( GFXTextureAddressMode,
  72. "The texture address modes.\n"
  73. "@ingroup GFX" )
  74. { GFXAddressWrap, "GFXAddressWrap" },
  75. { GFXAddressMirror, "GFXAddressMirror" },
  76. { GFXAddressClamp, "GFXAddressClamp" },
  77. { GFXAddressBorder, "GFXAddressBorder" },
  78. { GFXAddressMirrorOnce, "GFXAddressMirrorOnce" }
  79. EndImplementEnumType;
  80. ImplementEnumType( GFXTextureFilterType,
  81. "The texture filter types.\n"
  82. "@ingroup GFX" )
  83. { GFXTextureFilterNone, "GFXTextureFilterNone" },
  84. { GFXTextureFilterPoint, "GFXTextureFilterPoint" },
  85. { GFXTextureFilterLinear, "GFXTextureFilterLinear" },
  86. { GFXTextureFilterAnisotropic, "GFXTextureFilterAnisotropic" },
  87. { GFXTextureFilterPyramidalQuad, "GFXTextureFilterPyramidalQuad" },
  88. { GFXTextureFilterGaussianQuad, "GFXTextureFilterGaussianQuad" }
  89. EndImplementEnumType;
  90. ImplementEnumType( GFXTextureOp,
  91. "The texture operators.\n"
  92. "@ingroup GFX" )
  93. { GFXTOPDisable, "GFXTOPDisable" },
  94. { GFXTOPSelectARG1, "GFXTOPSelectARG1" },
  95. { GFXTOPSelectARG2, "GFXTOPSelectARG2" },
  96. { GFXTOPModulate, "GFXTOPModulate" },
  97. { GFXTOPModulate2X, "GFXTOPModulate2X" },
  98. { GFXTOPModulate4X, "GFXTOPModulate4X" },
  99. { GFXTOPAdd, "GFXTOPAdd" },
  100. { GFXTOPAddSigned, "GFXTOPAddSigned" },
  101. { GFXTOPAddSigned2X, "GFXTOPAddSigned2X" },
  102. { GFXTOPSubtract, "GFXTOPSubtract" },
  103. { GFXTOPAddSmooth, "GFXTOPAddSmooth" },
  104. { GFXTOPBlendDiffuseAlpha, "GFXTOPBlendDiffuseAlpha" },
  105. { GFXTOPBlendTextureAlpha, "GFXTOPBlendTextureAlpha" },
  106. { GFXTOPBlendFactorAlpha, "GFXTOPBlendFactorAlpha" },
  107. { GFXTOPBlendTextureAlphaPM, "GFXTOPBlendTextureAlphaPM" },
  108. { GFXTOPBlendCURRENTALPHA, "GFXTOPBlendCURRENTALPHA" },
  109. { GFXTOPPreModulate, "GFXTOPPreModulate" },
  110. { GFXTOPModulateAlphaAddColor, "GFXTOPModulateAlphaAddColor" },
  111. { GFXTOPModulateColorAddAlpha, "GFXTOPModulateColorAddAlpha" },
  112. { GFXTOPModulateInvAlphaAddColor, "GFXTOPModulateInvAlphaAddColor" },
  113. { GFXTOPModulateInvColorAddAlpha, "GFXTOPModulateInvColorAddAlpha" },
  114. { GFXTOPBumpEnvMap, "GFXTOPBumpEnvMap" },
  115. { GFXTOPBumpEnvMapLuminance, "GFXTOPBumpEnvMapLuminance" },
  116. { GFXTOPDotProduct3, "GFXTOPDotProduct3" },
  117. { GFXTOPLERP, "GFXTOPLERP" }
  118. EndImplementEnumType;
  119. ImplementEnumType( GFXTextureArgument,
  120. "The texture arguments.\n"
  121. "@ingroup GFX" )
  122. { GFXTADiffuse, "GFXTADiffuse" },
  123. { GFXTACurrent, "GFXTACurrent" },
  124. { GFXTATexture, "GFXTATexture" },
  125. { GFXTATFactor, "GFXTATFactor" },
  126. { GFXTASpecular, "GFXTASpecular" },
  127. { GFXTATemp, "GFXTATemp" },
  128. { GFXTAConstant, "GFXTAConstant" },
  129. { GFXTAComplement, "OneMinus" },
  130. { GFXTAAlphaReplicate, "AlphaReplicate" }
  131. EndImplementEnumType;
  132. ImplementEnumType( GFXTextureTransformFlags,
  133. "The texture transform state flags.\n"
  134. "@ingroup GFX" )
  135. { GFXTTFFDisable, "GFXTTFDisable" },
  136. { GFXTTFFCoord1D, "GFXTTFFCoord1D" },
  137. { GFXTTFFCoord2D, "GFXTTFFCoord2D" },
  138. { GFXTTFFCoord3D, "GFXTTFFCoord3D" },
  139. { GFXTTFFCoord4D, "GFXTTFFCoord4D" },
  140. { GFXTTFFProjected, "GFXTTFProjected" }
  141. EndImplementEnumType;
  142. ImplementEnumType( GFXFormat,
  143. "The texture formats.\n"
  144. "@note Not all formats are supported on all platforms.\n"
  145. "@ingroup GFX" )
  146. { GFXFormatR8G8B8, "GFXFormatR8G8B8" },
  147. { GFXFormatR8G8B8A8, "GFXFormatR8G8B8A8" },
  148. { GFXFormatR8G8B8X8, "GFXFormatR8G8B8X8" },
  149. { GFXFormatR32F, "GFXFormatR32F" },
  150. { GFXFormatR5G6B5, "GFXFormatR5G6B5" },
  151. { GFXFormatR5G5B5A1, "GFXFormatR5G5B5A1" },
  152. { GFXFormatR5G5B5X1, "GFXFormatR5G5B5X1" },
  153. { GFXFormatA4L4, "GFXFormatA4L4" },
  154. { GFXFormatA8L8, "GFXFormatA8L8" },
  155. { GFXFormatA8, "GFXFormatA8" },
  156. { GFXFormatL8, "GFXFormatL8" },
  157. { GFXFormatDXT1, "GFXFormatDXT1" },
  158. { GFXFormatDXT2, "GFXFormatDXT2" },
  159. { GFXFormatDXT3, "GFXFormatDXT3" },
  160. { GFXFormatDXT4, "GFXFormatDXT4" },
  161. { GFXFormatDXT5, "GFXFormatDXT5" },
  162. { GFXFormatD32, "GFXFormatD32" },
  163. { GFXFormatD24X8, "GFXFormatD24X8" },
  164. { GFXFormatD24S8, "GFXFormatD24S8" },
  165. { GFXFormatD24FS8, "GFXFormatD24FS8" },
  166. { GFXFormatD16, "GFXFormatD16" },
  167. { GFXFormatR32G32B32A32F, "GFXFormatR32G32B32A32F" },
  168. { GFXFormatR16G16B16A16F, "GFXFormatR16G16B16A16F" },
  169. { GFXFormatL16, "GFXFormatL16" },
  170. { GFXFormatR16G16B16A16, "GFXFormatR16G16B16A16" },
  171. { GFXFormatR16G16, "GFXFormatR16G16" },
  172. { GFXFormatR16F, "GFXFormatR16F" },
  173. { GFXFormatR16G16F, "GFXFormatR16G16F" },
  174. { GFXFormatR10G10B10A2, "GFXFormatR10G10B10A2" },
  175. EndImplementEnumType;
  176. ImplementEnumType( GFXCullMode,
  177. "The render cull modes.\n"
  178. "@ingroup GFX" )
  179. { GFXCullNone, "GFXCullNone" },
  180. { GFXCullCW, "GFXCullCW" },
  181. { GFXCullCCW, "GFXCullCCW" }
  182. EndImplementEnumType;
  183. ImplementEnumType( GFXStencilOp,
  184. "The stencil operators.\n"
  185. "@ingroup GFX" )
  186. { GFXStencilOpKeep, "GFXStencilOpKeep" },
  187. { GFXStencilOpZero, "GFXStencilOpZero" },
  188. { GFXStencilOpReplace, "GFXStencilOpReplace" },
  189. { GFXStencilOpIncrSat, "GFXStencilOpIncrSat" },
  190. { GFXStencilOpDecrSat, "GFXStencilOpDecrSat" },
  191. { GFXStencilOpInvert, "GFXStencilOpInvert" },
  192. { GFXStencilOpIncr, "GFXStencilOpIncr" },
  193. { GFXStencilOpDecr, "GFXStencilOpDecr" },
  194. EndImplementEnumType;
  195. ImplementEnumType( GFXBlendOp,
  196. "The blend operators.\n"
  197. "@ingroup GFX" )
  198. { GFXBlendOpAdd, "GFXBlendOpAdd" },
  199. { GFXBlendOpSubtract, "GFXBlendOpSubtract" },
  200. { GFXBlendOpRevSubtract, "GFXBlendOpRevSubtract" },
  201. { GFXBlendOpMin, "GFXBlendOpMin" },
  202. { GFXBlendOpMax, "GFXBlendOpMax" }
  203. EndImplementEnumType;