GraphicsDefs.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. //
  2. // Copyright (c) 2008-2016 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 Urho3D
  26. {
  27. class Vector3;
  28. /// Graphics capability support level. Web platform (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_DIRBILLBOARD = 4,
  52. GEOM_STATIC_NOINSTANCING = 5,
  53. MAX_GEOMETRYTYPES = 5,
  54. };
  55. /// Blending mode.
  56. enum BlendMode
  57. {
  58. BLEND_REPLACE = 0,
  59. BLEND_ADD,
  60. BLEND_MULTIPLY,
  61. BLEND_ALPHA,
  62. BLEND_ADDALPHA,
  63. BLEND_PREMULALPHA,
  64. BLEND_INVDESTALPHA,
  65. BLEND_SUBTRACT,
  66. BLEND_SUBTRACTALPHA,
  67. MAX_BLENDMODES
  68. };
  69. /// Depth or stencil compare mode.
  70. enum CompareMode
  71. {
  72. CMP_ALWAYS = 0,
  73. CMP_EQUAL,
  74. CMP_NOTEQUAL,
  75. CMP_LESS,
  76. CMP_LESSEQUAL,
  77. CMP_GREATER,
  78. CMP_GREATEREQUAL,
  79. MAX_COMPAREMODES
  80. };
  81. /// Culling mode.
  82. enum CullMode
  83. {
  84. CULL_NONE = 0,
  85. CULL_CCW,
  86. CULL_CW,
  87. MAX_CULLMODES
  88. };
  89. /// Fill mode.
  90. enum FillMode
  91. {
  92. FILL_SOLID = 0,
  93. FILL_WIREFRAME,
  94. FILL_POINT
  95. };
  96. /// Stencil operation.
  97. enum StencilOp
  98. {
  99. OP_KEEP = 0,
  100. OP_ZERO,
  101. OP_REF,
  102. OP_INCR,
  103. OP_DECR
  104. };
  105. /// Vertex/index buffer lock state.
  106. enum LockState
  107. {
  108. LOCK_NONE = 0,
  109. LOCK_HARDWARE,
  110. LOCK_SHADOW,
  111. LOCK_SCRATCH
  112. };
  113. /// Vertex elements.
  114. enum VertexElement
  115. {
  116. ELEMENT_POSITION = 0,
  117. ELEMENT_NORMAL,
  118. ELEMENT_COLOR,
  119. ELEMENT_TEXCOORD1,
  120. ELEMENT_TEXCOORD2,
  121. ELEMENT_CUBETEXCOORD1,
  122. ELEMENT_CUBETEXCOORD2,
  123. ELEMENT_TANGENT,
  124. ELEMENT_BLENDWEIGHTS,
  125. ELEMENT_BLENDINDICES,
  126. ELEMENT_INSTANCEMATRIX1,
  127. ELEMENT_INSTANCEMATRIX2,
  128. ELEMENT_INSTANCEMATRIX3,
  129. // Custom 32-bit integer object index. Due to API limitations, not supported on D3D9
  130. ELEMENT_OBJECTINDEX,
  131. MAX_VERTEX_ELEMENTS
  132. };
  133. /// Texture filtering mode.
  134. enum TextureFilterMode
  135. {
  136. FILTER_NEAREST = 0,
  137. FILTER_BILINEAR,
  138. FILTER_TRILINEAR,
  139. FILTER_ANISOTROPIC,
  140. FILTER_DEFAULT,
  141. MAX_FILTERMODES
  142. };
  143. /// Texture addressing mode.
  144. enum TextureAddressMode
  145. {
  146. ADDRESS_WRAP = 0,
  147. ADDRESS_MIRROR,
  148. ADDRESS_CLAMP,
  149. ADDRESS_BORDER,
  150. MAX_ADDRESSMODES
  151. };
  152. /// Texture coordinates.
  153. enum TextureCoordinate
  154. {
  155. COORD_U = 0,
  156. COORD_V,
  157. COORD_W,
  158. MAX_COORDS
  159. };
  160. /// Texture usage types.
  161. enum TextureUsage
  162. {
  163. TEXTURE_STATIC = 0,
  164. TEXTURE_DYNAMIC,
  165. TEXTURE_RENDERTARGET,
  166. TEXTURE_DEPTHSTENCIL
  167. };
  168. /// Cube map faces.
  169. enum CubeMapFace
  170. {
  171. FACE_POSITIVE_X = 0,
  172. FACE_NEGATIVE_X,
  173. FACE_POSITIVE_Y,
  174. FACE_NEGATIVE_Y,
  175. FACE_POSITIVE_Z,
  176. FACE_NEGATIVE_Z,
  177. MAX_CUBEMAP_FACES
  178. };
  179. /// Cubemap single image layout modes.
  180. enum CubeMapLayout
  181. {
  182. CML_HORIZONTAL = 0,
  183. CML_HORIZONTALNVIDIA,
  184. CML_HORIZONTALCROSS,
  185. CML_VERTICALCROSS,
  186. CML_BLENDER
  187. };
  188. /// Update mode for render surface viewports.
  189. enum RenderSurfaceUpdateMode
  190. {
  191. SURFACE_MANUALUPDATE = 0,
  192. SURFACE_UPDATEVISIBLE,
  193. SURFACE_UPDATEALWAYS
  194. };
  195. /// Shader types.
  196. enum ShaderType
  197. {
  198. VS = 0,
  199. PS,
  200. };
  201. /// Shader parameter groups for determining need to update. On APIs that support constant buffers, these correspond to different constant buffers.
  202. enum ShaderParameterGroup
  203. {
  204. SP_FRAME = 0,
  205. SP_CAMERA,
  206. SP_ZONE,
  207. SP_LIGHT,
  208. SP_MATERIAL,
  209. SP_OBJECT,
  210. SP_CUSTOM,
  211. MAX_SHADER_PARAMETER_GROUPS
  212. };
  213. /// Texture units.
  214. enum TextureUnit
  215. {
  216. TU_DIFFUSE = 0,
  217. TU_ALBEDOBUFFER = 0,
  218. TU_NORMAL = 1,
  219. TU_NORMALBUFFER = 1,
  220. TU_SPECULAR = 2,
  221. TU_EMISSIVE = 3,
  222. TU_ENVIRONMENT = 4,
  223. #ifdef DESKTOP_GRAPHICS
  224. TU_VOLUMEMAP = 5,
  225. TU_CUSTOM1 = 6,
  226. TU_CUSTOM2 = 7,
  227. TU_LIGHTRAMP = 8,
  228. TU_LIGHTSHAPE = 9,
  229. TU_SHADOWMAP = 10,
  230. TU_FACESELECT = 11,
  231. TU_INDIRECTION = 12,
  232. TU_DEPTHBUFFER = 13,
  233. TU_LIGHTBUFFER = 14,
  234. TU_ZONE = 15,
  235. MAX_MATERIAL_TEXTURE_UNITS = 8,
  236. MAX_TEXTURE_UNITS = 16
  237. #else
  238. TU_LIGHTRAMP = 5,
  239. TU_LIGHTSHAPE = 6,
  240. TU_SHADOWMAP = 7,
  241. MAX_MATERIAL_TEXTURE_UNITS = 5,
  242. MAX_TEXTURE_UNITS = 8
  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. FC_DIRECTION
  254. };
  255. /// Shadow type
  256. enum ShadowQuality
  257. {
  258. SHADOWQUALITY_SIMPLE_16BIT = 0,
  259. SHADOWQUALITY_SIMPLE_24BIT,
  260. SHADOWQUALITY_PCF_16BIT,
  261. SHADOWQUALITY_PCF_24BIT,
  262. SHADOWQUALITY_VSM,
  263. SHADOWQUALITY_BLUR_VSM
  264. };
  265. // Inbuilt shader parameters.
  266. extern URHO3D_API const StringHash VSP_AMBIENTSTARTCOLOR;
  267. extern URHO3D_API const StringHash VSP_AMBIENTENDCOLOR;
  268. extern URHO3D_API const StringHash VSP_BILLBOARDROT;
  269. extern URHO3D_API const StringHash VSP_CAMERAPOS;
  270. extern URHO3D_API const StringHash VSP_CAMERAROT;
  271. extern URHO3D_API const StringHash VSP_CLIPPLANE;
  272. extern URHO3D_API const StringHash VSP_NEARCLIP;
  273. extern URHO3D_API const StringHash VSP_FARCLIP;
  274. extern URHO3D_API const StringHash VSP_DEPTHMODE;
  275. extern URHO3D_API const StringHash VSP_DELTATIME;
  276. extern URHO3D_API const StringHash VSP_ELAPSEDTIME;
  277. extern URHO3D_API const StringHash VSP_FRUSTUMSIZE;
  278. extern URHO3D_API const StringHash VSP_GBUFFEROFFSETS;
  279. extern URHO3D_API const StringHash VSP_LIGHTDIR;
  280. extern URHO3D_API const StringHash VSP_LIGHTPOS;
  281. extern URHO3D_API const StringHash VSP_MODEL;
  282. extern URHO3D_API const StringHash VSP_VIEW;
  283. extern URHO3D_API const StringHash VSP_VIEWINV;
  284. extern URHO3D_API const StringHash VSP_VIEWPROJ;
  285. extern URHO3D_API const StringHash VSP_UOFFSET;
  286. extern URHO3D_API const StringHash VSP_VOFFSET;
  287. extern URHO3D_API const StringHash VSP_ZONE;
  288. extern URHO3D_API const StringHash VSP_LIGHTMATRICES;
  289. extern URHO3D_API const StringHash VSP_SKINMATRICES;
  290. extern URHO3D_API const StringHash VSP_VERTEXLIGHTS;
  291. extern URHO3D_API const StringHash PSP_AMBIENTCOLOR;
  292. extern URHO3D_API const StringHash PSP_CAMERAPOS;
  293. extern URHO3D_API const StringHash PSP_DELTATIME;
  294. extern URHO3D_API const StringHash PSP_DEPTHRECONSTRUCT;
  295. extern URHO3D_API const StringHash PSP_ELAPSEDTIME;
  296. extern URHO3D_API const StringHash PSP_FOGCOLOR;
  297. extern URHO3D_API const StringHash PSP_FOGPARAMS;
  298. extern URHO3D_API const StringHash PSP_GBUFFERINVSIZE;
  299. extern URHO3D_API const StringHash PSP_LIGHTCOLOR;
  300. extern URHO3D_API const StringHash PSP_LIGHTDIR;
  301. extern URHO3D_API const StringHash PSP_LIGHTPOS;
  302. extern URHO3D_API const StringHash PSP_MATDIFFCOLOR;
  303. extern URHO3D_API const StringHash PSP_MATEMISSIVECOLOR;
  304. extern URHO3D_API const StringHash PSP_MATENVMAPCOLOR;
  305. extern URHO3D_API const StringHash PSP_MATSPECCOLOR;
  306. extern URHO3D_API const StringHash PSP_NEARCLIP;
  307. extern URHO3D_API const StringHash PSP_FARCLIP;
  308. extern URHO3D_API const StringHash PSP_SHADOWCUBEADJUST;
  309. extern URHO3D_API const StringHash PSP_SHADOWDEPTHFADE;
  310. extern URHO3D_API const StringHash PSP_SHADOWINTENSITY;
  311. extern URHO3D_API const StringHash PSP_SHADOWMAPINVSIZE;
  312. extern URHO3D_API const StringHash PSP_SHADOWSPLITS;
  313. extern URHO3D_API const StringHash PSP_LIGHTMATRICES;
  314. extern URHO3D_API const StringHash PSP_VSMSHADOWPARAMS;
  315. extern URHO3D_API const StringHash PSP_ROUGHNESS;
  316. extern URHO3D_API const StringHash PSP_METALLIC;
  317. // Scale calculation from bounding box diagonal.
  318. extern URHO3D_API const Vector3 DOT_SCALE;
  319. static const int QUALITY_LOW = 0;
  320. static const int QUALITY_MEDIUM = 1;
  321. static const int QUALITY_HIGH = 2;
  322. static const int QUALITY_MAX = 15;
  323. static const unsigned CLEAR_COLOR = 0x1;
  324. static const unsigned CLEAR_DEPTH = 0x2;
  325. static const unsigned CLEAR_STENCIL = 0x4;
  326. static const unsigned MASK_NONE = 0x0;
  327. static const unsigned MASK_POSITION = 0x1;
  328. static const unsigned MASK_NORMAL = 0x2;
  329. static const unsigned MASK_COLOR = 0x4;
  330. static const unsigned MASK_TEXCOORD1 = 0x8;
  331. static const unsigned MASK_TEXCOORD2 = 0x10;
  332. static const unsigned MASK_CUBETEXCOORD1 = 0x20;
  333. static const unsigned MASK_CUBETEXCOORD2 = 0x40;
  334. static const unsigned MASK_TANGENT = 0x80;
  335. static const unsigned MASK_BLENDWEIGHTS = 0x100;
  336. static const unsigned MASK_BLENDINDICES = 0x200;
  337. static const unsigned MASK_INSTANCEMATRIX1 = 0x400;
  338. static const unsigned MASK_INSTANCEMATRIX2 = 0x800;
  339. static const unsigned MASK_INSTANCEMATRIX3 = 0x1000;
  340. static const unsigned MASK_OBJECTINDEX = 0x2000;
  341. static const unsigned MASK_DEFAULT = 0xffffffff;
  342. static const unsigned NO_ELEMENT = 0xffffffff;
  343. static const int MAX_RENDERTARGETS = 4;
  344. static const int MAX_VERTEX_STREAMS = 4;
  345. static const int MAX_CONSTANT_REGISTERS = 256;
  346. static const int BITS_PER_COMPONENT = 8;
  347. }