GraphicsDefs.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. //
  2. // Copyright (c) 2008-2015 the Urho3D project.
  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 deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // 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 FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #pragma once
  23. #include "../Container/HashBase.h"
  24. #include "../Math/StringHash.h"
  25. namespace Atomic
  26. {
  27. class Vector3;
  28. /// Graphics capability support level. HTML5 (Emscripten) also uses OpenGL ES, but is considered a desktop platform capability-wise
  29. #if defined(ANDROID) || defined(IOS) || defined(RPI)
  30. #define MOBILE_GRAPHICS
  31. #else
  32. #define DESKTOP_GRAPHICS
  33. #endif
  34. /// Primitive type.
  35. enum PrimitiveType
  36. {
  37. TRIANGLE_LIST = 0,
  38. LINE_LIST,
  39. POINT_LIST,
  40. TRIANGLE_STRIP,
  41. LINE_STRIP,
  42. TRIANGLE_FAN
  43. };
  44. /// %Geometry type.
  45. enum GeometryType
  46. {
  47. GEOM_STATIC = 0,
  48. GEOM_SKINNED = 1,
  49. GEOM_INSTANCED = 2,
  50. GEOM_BILLBOARD = 3,
  51. GEOM_STATIC_NOINSTANCING = 4,
  52. MAX_GEOMETRYTYPES = 4,
  53. };
  54. /// Blending mode.
  55. enum BlendMode
  56. {
  57. BLEND_REPLACE = 0,
  58. BLEND_ADD,
  59. BLEND_MULTIPLY,
  60. BLEND_ALPHA,
  61. BLEND_ADDALPHA,
  62. BLEND_PREMULALPHA,
  63. BLEND_INVDESTALPHA,
  64. BLEND_SUBTRACT,
  65. BLEND_SUBTRACTALPHA,
  66. MAX_BLENDMODES
  67. };
  68. /// Depth or stencil compare mode.
  69. enum CompareMode
  70. {
  71. CMP_ALWAYS = 0,
  72. CMP_EQUAL,
  73. CMP_NOTEQUAL,
  74. CMP_LESS,
  75. CMP_LESSEQUAL,
  76. CMP_GREATER,
  77. CMP_GREATEREQUAL,
  78. MAX_COMPAREMODES
  79. };
  80. /// Culling mode.
  81. enum CullMode
  82. {
  83. CULL_NONE = 0,
  84. CULL_CCW,
  85. CULL_CW,
  86. MAX_CULLMODES
  87. };
  88. /// Fill mode.
  89. enum FillMode
  90. {
  91. FILL_SOLID = 0,
  92. FILL_WIREFRAME,
  93. FILL_POINT
  94. };
  95. /// Stencil operation.
  96. enum StencilOp
  97. {
  98. OP_KEEP = 0,
  99. OP_ZERO,
  100. OP_REF,
  101. OP_INCR,
  102. OP_DECR
  103. };
  104. /// Vertex/index buffer lock state.
  105. enum LockState
  106. {
  107. LOCK_NONE = 0,
  108. LOCK_HARDWARE,
  109. LOCK_SHADOW,
  110. LOCK_SCRATCH
  111. };
  112. /// Vertex elements.
  113. enum VertexElement
  114. {
  115. ELEMENT_POSITION = 0,
  116. ELEMENT_NORMAL,
  117. ELEMENT_COLOR,
  118. ELEMENT_TEXCOORD1,
  119. ELEMENT_TEXCOORD2,
  120. ELEMENT_CUBETEXCOORD1,
  121. ELEMENT_CUBETEXCOORD2,
  122. ELEMENT_TANGENT,
  123. ELEMENT_BLENDWEIGHTS,
  124. ELEMENT_BLENDINDICES,
  125. ELEMENT_INSTANCEMATRIX1,
  126. ELEMENT_INSTANCEMATRIX2,
  127. ELEMENT_INSTANCEMATRIX3,
  128. MAX_VERTEX_ELEMENTS
  129. };
  130. /// Texture filtering mode.
  131. enum TextureFilterMode
  132. {
  133. FILTER_NEAREST = 0,
  134. FILTER_BILINEAR,
  135. FILTER_TRILINEAR,
  136. FILTER_ANISOTROPIC,
  137. FILTER_DEFAULT,
  138. MAX_FILTERMODES
  139. };
  140. /// Texture addressing mode.
  141. enum TextureAddressMode
  142. {
  143. ADDRESS_WRAP = 0,
  144. ADDRESS_MIRROR,
  145. ADDRESS_CLAMP,
  146. ADDRESS_BORDER,
  147. MAX_ADDRESSMODES
  148. };
  149. /// Texture coordinates.
  150. enum TextureCoordinate
  151. {
  152. COORD_U = 0,
  153. COORD_V,
  154. COORD_W,
  155. MAX_COORDS
  156. };
  157. /// Texture usage types.
  158. enum TextureUsage
  159. {
  160. TEXTURE_STATIC = 0,
  161. TEXTURE_DYNAMIC,
  162. TEXTURE_RENDERTARGET,
  163. TEXTURE_DEPTHSTENCIL
  164. };
  165. /// Cube map faces.
  166. enum CubeMapFace
  167. {
  168. FACE_POSITIVE_X = 0,
  169. FACE_NEGATIVE_X,
  170. FACE_POSITIVE_Y,
  171. FACE_NEGATIVE_Y,
  172. FACE_POSITIVE_Z,
  173. FACE_NEGATIVE_Z,
  174. MAX_CUBEMAP_FACES
  175. };
  176. /// Cubemap single image layout modes.
  177. enum CubeMapLayout
  178. {
  179. CML_HORIZONTAL = 0,
  180. CML_HORIZONTALNVIDIA,
  181. CML_HORIZONTALCROSS,
  182. CML_VERTICALCROSS,
  183. CML_BLENDER
  184. };
  185. /// Update mode for render surface viewports.
  186. enum RenderSurfaceUpdateMode
  187. {
  188. SURFACE_MANUALUPDATE = 0,
  189. SURFACE_UPDATEVISIBLE,
  190. SURFACE_UPDATEALWAYS
  191. };
  192. /// Shader types.
  193. enum ShaderType
  194. {
  195. VS = 0,
  196. PS,
  197. };
  198. /// Shader parameter groups for determining need to update. On APIs that support constant buffers, these correspond to different constant buffers.
  199. enum ShaderParameterGroup
  200. {
  201. SP_FRAME = 0,
  202. SP_CAMERA,
  203. SP_ZONE,
  204. SP_LIGHT,
  205. SP_MATERIAL,
  206. SP_OBJECT,
  207. SP_CUSTOM,
  208. MAX_SHADER_PARAMETER_GROUPS
  209. };
  210. /// Texture units.
  211. enum TextureUnit
  212. {
  213. TU_DIFFUSE = 0,
  214. TU_ALBEDOBUFFER = 0,
  215. TU_NORMAL = 1,
  216. TU_NORMALBUFFER = 1,
  217. TU_SPECULAR = 2,
  218. TU_EMISSIVE = 3,
  219. TU_ENVIRONMENT = 4,
  220. #ifdef DESKTOP_GRAPHICS
  221. TU_VOLUMEMAP = 5,
  222. TU_CUSTOM1 = 6,
  223. TU_CUSTOM2 = 7,
  224. TU_LIGHTRAMP = 8,
  225. TU_LIGHTSHAPE = 9,
  226. TU_SHADOWMAP = 10,
  227. TU_FACESELECT = 11,
  228. TU_INDIRECTION = 12,
  229. TU_DEPTHBUFFER = 13,
  230. TU_LIGHTBUFFER = 14,
  231. TU_ZONE = 15,
  232. MAX_MATERIAL_TEXTURE_UNITS = 8,
  233. MAX_TEXTURE_UNITS = 16
  234. #else
  235. #error JSBind has a enum collision as doesn't know about "DESKTOP_GRAPHICS
  236. /*
  237. TU_LIGHTRAMP = 5,
  238. TU_LIGHTSHAPE = 6,
  239. TU_SHADOWMAP = 7,
  240. MAX_MATERIAL_TEXTURE_UNITS = 5,
  241. MAX_TEXTURE_UNITS = 8
  242. */
  243. #endif
  244. };
  245. /// Billboard camera facing modes.
  246. enum FaceCameraMode
  247. {
  248. FC_NONE = 0,
  249. FC_ROTATE_XYZ,
  250. FC_ROTATE_Y,
  251. FC_LOOKAT_XYZ,
  252. FC_LOOKAT_Y
  253. };
  254. // Inbuilt shader parameters.
  255. extern ATOMIC_API const StringHash VSP_AMBIENTSTARTCOLOR;
  256. extern ATOMIC_API const StringHash VSP_AMBIENTENDCOLOR;
  257. extern ATOMIC_API const StringHash VSP_BILLBOARDROT;
  258. extern ATOMIC_API const StringHash VSP_CAMERAPOS;
  259. extern ATOMIC_API const StringHash VSP_CAMERAROT;
  260. extern ATOMIC_API const StringHash VSP_CLIPPLANE;
  261. extern ATOMIC_API const StringHash VSP_NEARCLIP;
  262. extern ATOMIC_API const StringHash VSP_FARCLIP;
  263. extern ATOMIC_API const StringHash VSP_DEPTHMODE;
  264. extern ATOMIC_API const StringHash VSP_DELTATIME;
  265. extern ATOMIC_API const StringHash VSP_ELAPSEDTIME;
  266. extern ATOMIC_API const StringHash VSP_FRUSTUMSIZE;
  267. extern ATOMIC_API const StringHash VSP_GBUFFEROFFSETS;
  268. extern ATOMIC_API const StringHash VSP_LIGHTDIR;
  269. extern ATOMIC_API const StringHash VSP_LIGHTPOS;
  270. extern ATOMIC_API const StringHash VSP_MODEL;
  271. extern ATOMIC_API const StringHash VSP_VIEWPROJ;
  272. extern ATOMIC_API const StringHash VSP_UOFFSET;
  273. extern ATOMIC_API const StringHash VSP_VOFFSET;
  274. extern ATOMIC_API const StringHash VSP_LMOFFSET;
  275. extern ATOMIC_API const StringHash VSP_ZONE;
  276. extern ATOMIC_API const StringHash VSP_LIGHTMATRICES;
  277. extern ATOMIC_API const StringHash VSP_SKINMATRICES;
  278. extern ATOMIC_API const StringHash VSP_VERTEXLIGHTS;
  279. extern ATOMIC_API const StringHash PSP_AMBIENTCOLOR;
  280. extern ATOMIC_API const StringHash PSP_CAMERAPOS;
  281. extern ATOMIC_API const StringHash PSP_DELTATIME;
  282. extern ATOMIC_API const StringHash PSP_DEPTHRECONSTRUCT;
  283. extern ATOMIC_API const StringHash PSP_ELAPSEDTIME;
  284. extern ATOMIC_API const StringHash PSP_FOGCOLOR;
  285. extern ATOMIC_API const StringHash PSP_FOGPARAMS;
  286. extern ATOMIC_API const StringHash PSP_GBUFFERINVSIZE;
  287. extern ATOMIC_API const StringHash PSP_LIGHTCOLOR;
  288. extern ATOMIC_API const StringHash PSP_LIGHTDIR;
  289. extern ATOMIC_API const StringHash PSP_LIGHTPOS;
  290. extern ATOMIC_API const StringHash PSP_MATDIFFCOLOR;
  291. extern ATOMIC_API const StringHash PSP_MATEMISSIVECOLOR;
  292. extern ATOMIC_API const StringHash PSP_MATENVMAPCOLOR;
  293. extern ATOMIC_API const StringHash PSP_MATSPECCOLOR;
  294. extern ATOMIC_API const StringHash PSP_NEARCLIP;
  295. extern ATOMIC_API const StringHash PSP_FARCLIP;
  296. extern ATOMIC_API const StringHash PSP_SHADOWCUBEADJUST;
  297. extern ATOMIC_API const StringHash PSP_SHADOWDEPTHFADE;
  298. extern ATOMIC_API const StringHash PSP_SHADOWINTENSITY;
  299. extern ATOMIC_API const StringHash PSP_SHADOWMAPINVSIZE;
  300. extern ATOMIC_API const StringHash PSP_SHADOWSPLITS;
  301. extern ATOMIC_API const StringHash PSP_LIGHTMATRICES;
  302. // Scale calculation from bounding box diagonal.
  303. extern ATOMIC_API const Vector3 DOT_SCALE;
  304. static const int QUALITY_LOW = 0;
  305. static const int QUALITY_MEDIUM = 1;
  306. static const int QUALITY_HIGH = 2;
  307. static const int QUALITY_MAX = 15;
  308. static const int SHADOWQUALITY_LOW_16BIT = 0;
  309. static const int SHADOWQUALITY_LOW_24BIT = 1;
  310. static const int SHADOWQUALITY_HIGH_16BIT = 2;
  311. static const int SHADOWQUALITY_HIGH_24BIT = 3;
  312. static const unsigned CLEAR_COLOR = 0x1;
  313. static const unsigned CLEAR_DEPTH = 0x2;
  314. static const unsigned CLEAR_STENCIL = 0x4;
  315. static const unsigned MASK_NONE = 0x0;
  316. static const unsigned MASK_POSITION = 0x1;
  317. static const unsigned MASK_NORMAL = 0x2;
  318. static const unsigned MASK_COLOR = 0x4;
  319. static const unsigned MASK_TEXCOORD1 = 0x8;
  320. static const unsigned MASK_TEXCOORD2 = 0x10;
  321. static const unsigned MASK_CUBETEXCOORD1 = 0x20;
  322. static const unsigned MASK_CUBETEXCOORD2 = 0x40;
  323. static const unsigned MASK_TANGENT = 0x80;
  324. static const unsigned MASK_BLENDWEIGHTS = 0x100;
  325. static const unsigned MASK_BLENDINDICES = 0x200;
  326. static const unsigned MASK_INSTANCEMATRIX1 = 0x400;
  327. static const unsigned MASK_INSTANCEMATRIX2 = 0x800;
  328. static const unsigned MASK_INSTANCEMATRIX3 = 0x1000;
  329. static const unsigned MASK_DEFAULT = 0xffffffff;
  330. static const unsigned NO_ELEMENT = 0xffffffff;
  331. static const int MAX_RENDERTARGETS = 4;
  332. static const int MAX_VERTEX_STREAMS = 4;
  333. static const int MAX_CONSTANT_REGISTERS = 256;
  334. static const int BITS_PER_COMPONENT = 8;
  335. }