CmPrerequisites.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. /*-------------------------------------------------------------------------
  2. This source file is a part of OGRE
  3. (Object-oriented Graphics Rendering Engine)
  4. For the latest info, see http://www.ogre3d.org/
  5. Copyright (c) 2000-2011 Torus Knot Software Ltd
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  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. #ifndef __OgrePrerequisites_H__
  23. #define __OgrePrerequisites_H__
  24. #include "CmPrerequisitesUtil.h"
  25. #define CM_MAX_MULTIPLE_RENDER_TARGETS 8
  26. #define CM_FORCE_SINGLETHREADED_RENDERING 0
  27. //----------------------------------------------------------------------------
  28. // Windows Settings
  29. #if CM_PLATFORM == CM_PLATFORM_WIN32
  30. // If we're not including this from a client build, specify that the stuff
  31. // should get exported. Otherwise, import it.
  32. # if defined( CM_STATIC_LIB )
  33. // Linux compilers don't have symbol import/export directives.
  34. # define CM_EXPORT
  35. # else
  36. # if defined( CM_EXPORTS )
  37. # define CM_EXPORT __declspec( dllexport )
  38. # else
  39. # if defined( __MINGW32__ )
  40. # define CM_EXPORT
  41. # else
  42. # define CM_EXPORT __declspec( dllimport )
  43. # endif
  44. # endif
  45. # endif
  46. // Win32 compilers use _DEBUG for specifying debug builds.
  47. // for MinGW, we set DEBUG
  48. # if defined(_DEBUG) || defined(DEBUG)
  49. # define CM_DEBUG_MODE 1
  50. # else
  51. # define CM_DEBUG_MODE 0
  52. # endif
  53. #endif // CM_PLATFORM == CM_PLATFORM_WIN32
  54. // Linux/Apple Settings
  55. #if CM_PLATFORM == CM_PLATFORM_LINUX || CM_PLATFORM == CM_PLATFORM_APPLE
  56. // Enable GCC symbol visibility
  57. # if defined( CM_GCC_VISIBILITY )
  58. # define CM_EXPORT __attribute__ ((visibility("default")))
  59. # define CM_HIDDEN __attribute__ ((visibility("hidden")))
  60. # else
  61. # define CM_EXPORT
  62. # define CM_HIDDEN
  63. # endif
  64. // A quick define to overcome different names for the same function
  65. # define stricmp strcasecmp
  66. # ifdef DEBUG
  67. # define CM_DEBUG_MODE 1
  68. # else
  69. # define CM_DEBUG_MODE 0
  70. # endif
  71. #endif
  72. #include "CmMemAllocCategories.h"
  73. namespace CamelotFramework {
  74. enum HeapID
  75. {
  76. HID_Main = 0,
  77. HID_Render = 1
  78. };
  79. // Pre-declare classes
  80. // Allows use of pointers in header files without including individual .h
  81. // so decreases dependencies between files
  82. class Color;
  83. class GpuProgram;
  84. class GpuProgramManager;
  85. class IndexBuffer;
  86. class OcclusionQuery;
  87. class VertexBuffer;
  88. class PixelBuffer;
  89. class GpuBuffer;
  90. class HighLevelGpuProgram;
  91. class HighLevelGpuProgramManager;
  92. class HighLevelGpuProgramFactory;
  93. class IndexData;
  94. class Pass;
  95. class Technique;
  96. class Shader;
  97. class Material;
  98. class RenderSystem;
  99. class RenderSystemCapabilities;
  100. class RenderTarget;
  101. class RenderTexture;
  102. class MultiRenderTexture;
  103. class RenderWindow;
  104. struct RenderOpMesh;
  105. class StringInterface;
  106. class SamplerState;
  107. class TextureManager;
  108. class Viewport;
  109. class VertexData;
  110. class VertexDeclaration;
  111. class Input;
  112. class RawInputHandler;
  113. class Renderer;
  114. class RendererFactory;
  115. class WorkQueue;
  116. class PassParameters;
  117. class AsyncOp;
  118. class HardwareBufferManager;
  119. class FontManager;
  120. class DepthStencilState;
  121. class RenderStateManager;
  122. class RasterizerState;
  123. class BlendState;
  124. class GpuParamBlock;
  125. class GpuParamBlockBuffer;
  126. class GpuParams;
  127. struct GpuParamDesc;
  128. struct GpuParamDataDesc;
  129. struct GpuParamObjectDesc;
  130. struct GpuParamBlockDesc;
  131. class GpuProgInclude;
  132. class TextureView;
  133. class CoreObject;
  134. class ImportOptions;
  135. struct FontData;
  136. class GameObject;
  137. class GpuResource;
  138. class GpuResourceData;
  139. class BindableGpuParams;
  140. struct RenderOperation;
  141. class RenderQueue;
  142. // Asset import
  143. class SpecificImporter;
  144. class Importer;
  145. // Resources
  146. class Resource;
  147. class Resources;
  148. class Texture;
  149. class Mesh;
  150. class Font;
  151. // Scene
  152. class SceneObject;
  153. class Component;
  154. class SceneManager;
  155. // RTTI
  156. class MeshRTTI;
  157. // Desc structs
  158. struct SAMPLER_STATE_DESC;
  159. struct DEPTH_STENCIL_STATE_DESC;
  160. struct RASTERIZER_STATE_DESC;
  161. struct BLEND_STATE_DESC;
  162. struct RENDER_TARGET_BLEND_STATE_DESC;
  163. struct RENDER_TEXTURE_DESC;
  164. struct RENDER_WINDOW_DESC;
  165. struct FONT_DESC;
  166. template<class T>
  167. class CoreThreadAccessor;
  168. class CommandQueueNoSync;
  169. class CommandQueueSync;
  170. }
  171. /************************************************************************/
  172. /* Shared pointer typedefs */
  173. /************************************************************************/
  174. namespace CamelotFramework
  175. {
  176. typedef std::shared_ptr<GpuProgram> GpuProgramPtr;
  177. typedef std::shared_ptr<HighLevelGpuProgram> HighLevelGpuProgramPtr;
  178. typedef std::shared_ptr<PixelBuffer> PixelBufferPtr;
  179. typedef std::shared_ptr<VertexBuffer> VertexBufferPtr;
  180. typedef std::shared_ptr<IndexBuffer> IndexBufferPtr;
  181. typedef std::shared_ptr<GpuBuffer> GpuBufferPtr;
  182. typedef std::shared_ptr<VertexDeclaration> VertexDeclarationPtr;
  183. typedef std::shared_ptr<Mesh> MeshPtr;
  184. typedef std::shared_ptr<Texture> TexturePtr;
  185. typedef std::shared_ptr<Resource> ResourcePtr;
  186. typedef std::shared_ptr<Technique> TechniquePtr;
  187. typedef std::shared_ptr<Pass> PassPtr;
  188. typedef std::shared_ptr<Shader> ShaderPtr;
  189. typedef std::shared_ptr<Material> MaterialPtr;
  190. typedef std::shared_ptr<Renderer> RendererPtr;
  191. typedef std::shared_ptr<RendererFactory> RendererFactoryPtr;
  192. typedef std::shared_ptr<WorkQueue> WorkQueuePtr;
  193. typedef std::shared_ptr<PassParameters> PassParametersPtr;
  194. typedef std::shared_ptr<Component> ComponentPtr;
  195. typedef std::shared_ptr<SceneObject> GameObjectPtr;
  196. typedef std::shared_ptr<SamplerState> SamplerStatePtr;
  197. typedef std::shared_ptr<DepthStencilState> DepthStencilStatePtr;
  198. typedef std::shared_ptr<RasterizerState> RasterizerStatePtr;
  199. typedef std::shared_ptr<BlendState> BlendStatePtr;
  200. typedef std::shared_ptr<RenderWindow> RenderWindowPtr;
  201. typedef std::shared_ptr<RenderTarget> RenderTargetPtr;
  202. typedef std::shared_ptr<RenderTexture> RenderTexturePtr;
  203. typedef std::shared_ptr<MultiRenderTexture> MultiRenderTexturePtr;
  204. typedef std::shared_ptr<GpuParamBlock> GpuParamBlockPtr;
  205. typedef std::shared_ptr<GpuParamBlockBuffer> GpuParamBlockBufferPtr;
  206. typedef std::shared_ptr<GpuParams> GpuParamsPtr;
  207. typedef std::shared_ptr<TextureView> TextureViewPtr;
  208. typedef std::shared_ptr<Viewport> ViewportPtr;
  209. typedef std::shared_ptr<GpuProgInclude> GpuProgIncludePtr;
  210. typedef std::shared_ptr<ImportOptions> ImportOptionsPtr;
  211. typedef std::shared_ptr<const ImportOptions> ConstImportOptionsPtr;
  212. typedef std::shared_ptr<Font> FontPtr;
  213. typedef std::shared_ptr<GpuResource> GpuResourcePtr;
  214. typedef CoreThreadAccessor<CommandQueueNoSync> CoreAccessor;
  215. typedef CoreThreadAccessor<CommandQueueSync> SyncedCoreAccessor;
  216. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueNoSync>> CoreAccessorPtr;
  217. typedef std::shared_ptr<CoreThreadAccessor<CommandQueueSync>> SyncedCoreAccessorPtr;
  218. }
  219. /************************************************************************/
  220. /* RTTI */
  221. /************************************************************************/
  222. namespace CamelotFramework
  223. {
  224. enum TypeID_Core
  225. {
  226. TID_Texture = 1001,
  227. TID_Mesh = 1002,
  228. TID_MeshData = 1003,
  229. TID_VertexDeclaration = 1004,
  230. TID_VertexElementData = 1005,
  231. TID_Component = 1006,
  232. TID_ResourceHandle = 1009,
  233. TID_GpuProgram = 1010,
  234. TID_ResourceHandleData = 1011,
  235. TID_CgProgram = 1012,
  236. TID_ResourceMetaData = 1013,
  237. TID_Pass = 1014,
  238. TID_Technique = 1015,
  239. TID_Shader = 1016,
  240. TID_Material = 1017,
  241. TID_MaterialParams = 1018,
  242. TID_FloatParamKVP = 1019,
  243. TID_MaterialTexParamKVP = 1020,
  244. TID_SamplerState = 1021,
  245. TID_SamplerStateParamKVP = 1022,
  246. TID_BlendState = 1023,
  247. TID_RasterizerState = 1024,
  248. TID_DepthStencilState = 1025,
  249. TID_MaterialParamFloat = 1026,
  250. TID_MaterialParamVec2 = 1027,
  251. TID_MaterialParamVec3 = 1028,
  252. TID_MaterialParamVec4 = 1029,
  253. TID_MaterialParamMat3 = 1030,
  254. TID_MaterialParamMat4 = 1031,
  255. TID_MaterialParamTexture = 1032,
  256. TID_MaterialParamSamplerState = 1033,
  257. TID_BLEND_STATE_DESC = 1034,
  258. TID_SHADER_DATA_PARAM_DESC = 1035,
  259. TID_SHADER_OBJECT_PARAM_DESC = 1036,
  260. TID_SHADER_PARAM_BLOCK_DESC = 1047,
  261. TID_ImportOptions = 1048,
  262. TID_GpuProgramImportOptions = 1049,
  263. TID_MaterialParamStruct = 1050,
  264. TID_Font = 1051,
  265. TID_FONT_DESC = 1052,
  266. TID_CHAR_DESC = 1053,
  267. TID_STDVECTOR = 1054,
  268. TID_STDMAP = 1055,
  269. TID_FontImportOptions = 1056,
  270. TID_FontData = 1057,
  271. TID_SceneObject = 1059,
  272. TID_GameObject = 1060,
  273. TID_GpuResource = 1061,
  274. TID_PixelData = 1062,
  275. TID_GpuResourceData = 1063
  276. };
  277. }
  278. /************************************************************************/
  279. /* Resource references */
  280. /************************************************************************/
  281. #include "CmResourceHandle.h"
  282. namespace CamelotFramework
  283. {
  284. // Resource handles
  285. typedef ResourceHandle<Resource> HResource;
  286. typedef ResourceHandle<Texture> HTexture;
  287. typedef ResourceHandle<Mesh> HMesh;
  288. typedef ResourceHandle<GpuProgram> HGpuProgram;
  289. typedef ResourceHandle<HighLevelGpuProgram> HHighLevelGpuProgram;
  290. typedef ResourceHandle<Material> HMaterial;
  291. typedef ResourceHandle<SamplerState> HSamplerState;
  292. typedef ResourceHandle<RasterizerState> HRasterizerState;
  293. typedef ResourceHandle<DepthStencilState> HDepthStencilState;
  294. typedef ResourceHandle<BlendState> HBlendState;
  295. typedef ResourceHandle<GpuProgInclude> HGpuProgInclude;
  296. typedef ResourceHandle<Font> HFont;
  297. }
  298. namespace CamelotFramework
  299. {
  300. /**
  301. * @brief Defers function execution until the next frame. If this function is called
  302. * within another deferred call, then it will be executed the same frame,
  303. * but only after all existing deferred calls are done.
  304. *
  305. * @note This method can be used for breaking dependencies among other things. If a class
  306. * A depends on class B having something done, but class B also depends in some way on class A,
  307. * you can break up the initialization into two separate steps, queuing the second step
  308. * using this method.
  309. *
  310. * Similar situation can happen if you have multiple classes being initialized in an undefined order
  311. * but some of them depend on others. Using this method you can defer the dependent step until next frame,
  312. * which will ensure everything was initialized.
  313. *
  314. * @param callback The callback.
  315. */
  316. void CM_EXPORT deferredCall(std::function<void()> callback);
  317. }
  318. #endif