CmD3D9Prerequisites.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. -----------------------------------------------------------------------------
  3. This source file is part of OGRE
  4. (Object-oriented Graphics Rendering Engine)
  5. For the latest info, see http://www.ogre3d.org/
  6. Copyright (c) 2000-2011 Torus Knot Software Ltd
  7. Permission is hereby granted, free of charge, to any person obtaining a copy
  8. of this software and associated documentation files (the "Software"), to deal
  9. in the Software without restriction, including without limitation the rights
  10. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. copies of the Software, and to permit persons to whom the Software is
  12. furnished to do so, subject to the following conditions:
  13. The above copyright notice and this permission notice shall be included in
  14. all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. THE SOFTWARE.
  22. -----------------------------------------------------------------------------
  23. */
  24. #ifndef __D3D9PREREQUISITES_H__
  25. #define __D3D9PREREQUISITES_H__
  26. #include "CmPrerequisites.h"
  27. #ifdef __MINGW32__
  28. # include "WIN32/OgreMinGWSupport.h" // extra defines for MinGW to deal with DX SDK
  29. #endif
  30. #if CM_THREAD_SUPPORT
  31. #define OGRE_LOCK_RECURSIVE_MUTEX(name) name.lock();
  32. #define OGRE_UNLOCK_RECURSIVE_MUTEX(name) name.unlock();
  33. #else
  34. #define OGRE_LOCK_RECURSIVE_MUTEX(name)
  35. #define OGRE_UNLOCK_RECURSIVE_MUTEX(name)
  36. #endif
  37. #if CM_THREAD_SUPPORT == 1
  38. #define D3D9_DEVICE_ACCESS_LOCK OGRE_LOCK_RECURSIVE_MUTEX(msDeviceAccessMutex);
  39. #define D3D9_DEVICE_ACCESS_UNLOCK OGRE_UNLOCK_RECURSIVE_MUTEX(msDeviceAccessMutex);
  40. #define D3D9_DEVICE_ACCESS_CRITICAL_SECTION CM_LOCK_MUTEX(msDeviceAccessMutex)
  41. #else
  42. #define D3D9_DEVICE_ACCESS_LOCK
  43. #define D3D9_DEVICE_ACCESS_UNLOCK
  44. #define D3D9_DEVICE_ACCESS_CRITICAL_SECTION
  45. #endif
  46. // Define versions for if DirectX is in use (Win32 only)
  47. #define DIRECT3D_VERSION 0x0900
  48. // some D3D commonly used macros
  49. #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
  50. #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
  51. #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
  52. // enable extended d3d debug
  53. #if CM_DEBUG_MODE
  54. # define D3D_DEBUG_INFO
  55. #endif
  56. #define WIN32_LEAN_AND_MEAN
  57. #if !defined(NOMINMAX) && defined(_MSC_VER)
  58. # define NOMINMAX // required to stop windows.h messing up std::min
  59. #endif
  60. #include <d3d9.h>
  61. #include <d3dx9.h>
  62. #include <DxErr.h>
  63. namespace CamelotEngine
  64. {
  65. // Predefine classes
  66. class D3D9RenderSystem;
  67. class D3D9RenderWindow;
  68. class D3D9Texture;
  69. class D3D9TextureManager;
  70. class D3D9Driver;
  71. class D3D9DriverList;
  72. class D3D9VideoMode;
  73. class D3D9VideoModeList;
  74. class D3D9GpuProgram;
  75. class D3D9GpuProgramManager;
  76. class D3D9HardwareBufferManager;
  77. class D3D9HardwareIndexBuffer;
  78. class D3D9HLSLProgramFactory;
  79. class D3D9HLSLProgram;
  80. class D3D9VertexDeclaration;
  81. class D3D9Resource;
  82. // Should we ask D3D to manage vertex/index buffers automatically?
  83. // Doing so avoids lost devices, but also has a performance impact
  84. // which is unacceptably bad when using very large buffers
  85. #define OGRE_D3D_MANAGE_BUFFERS 1 // TODO - Keep this on or off? I'll probably want to turn it off at some point
  86. //-------------------------------------------
  87. // Windows setttings
  88. //-------------------------------------------
  89. #if (CM_PLATFORM == CM_PLATFORM_WIN32) && !defined(CM_STATIC_LIB)
  90. # ifdef OGRED3DENGINEDLL_EXPORTS
  91. # define _OgreD3D9Export __declspec(dllexport)
  92. # else
  93. # if defined( __MINGW32__ )
  94. # define _OgreD3D9Export
  95. # else
  96. # define _OgreD3D9Export __declspec(dllimport)
  97. # endif
  98. # endif
  99. #else
  100. # define _OgreD3D9Export
  101. #endif // OGRE_WIN32
  102. }
  103. #endif