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 7 Copyright (c) 2000-2013 Torus Knot Software Ltd 8 9 Permission is hereby granted, free of charge, to any person obtaining a copy 10 of this software and associated documentation files (the "Software"), to deal 11 in the Software without restriction, including without limitation the rights 12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 copies of the Software, and to permit persons to whom the Software is 14 furnished to do so, subject to the following conditions: 15 16 The above copyright notice and this permission notice shall be included in 17 all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 THE SOFTWARE. 26 ----------------------------------------------------------------------------- 27 */ 28 #ifndef __D3D9PREREQUISITES_H__ 29 #define __D3D9PREREQUISITES_H__ 30 31 #include "OgrePrerequisites.h" 32 #ifdef __MINGW32__ 33 # include "WIN32/OgreMinGWSupport.h" // extra defines for MinGW to deal with DX SDK 34 #endif 35 36 #include "Threading/OgreThreadHeaders.h" 37 38 #if OGRE_THREAD_SUPPORT 39 # define OGRE_LOCK_RECURSIVE_MUTEX(name) name.lock(); 40 # define OGRE_UNLOCK_RECURSIVE_MUTEX(name) name.unlock(); 41 #else 42 # define OGRE_LOCK_RECURSIVE_MUTEX(name) 43 # define OGRE_UNLOCK_RECURSIVE_MUTEX(name) 44 #endif 45 46 #if OGRE_THREAD_SUPPORT == 1 47 # define D3D9_DEVICE_ACCESS_LOCK OGRE_LOCK_RECURSIVE_MUTEX(msDeviceAccessMutex); 48 # define D3D9_DEVICE_ACCESS_UNLOCK OGRE_UNLOCK_RECURSIVE_MUTEX(msDeviceAccessMutex); 49 # define D3D9_DEVICE_ACCESS_CRITICAL_SECTION OGRE_LOCK_MUTEX(msDeviceAccessMutex); 50 #else 51 # define D3D9_DEVICE_ACCESS_LOCK 52 # define D3D9_DEVICE_ACCESS_UNLOCK 53 # define D3D9_DEVICE_ACCESS_CRITICAL_SECTION 54 #endif 55 56 // Define versions for if DirectX is in use (Win32 only) 57 #define DIRECT3D_VERSION 0x0900 58 59 // some D3D commonly used macros 60 #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } 61 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } 62 #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } 63 64 // enable extended d3d debug 65 #if OGRE_DEBUG_MODE 66 # define D3D_DEBUG_INFO 67 #endif 68 69 #define WIN32_LEAN_AND_MEAN 70 #if !defined(NOMINMAX) && defined(_MSC_VER) 71 # define NOMINMAX // required to stop windows.h messing up std::min 72 #endif 73 #include <d3d9.h> 74 #include <d3dx9.h> 75 #include <DxErr.h> 76 77 78 namespace Ogre 79 { 80 // Predefine classes 81 class D3D9DepthBuffer; 82 class D3D9RenderSystem; 83 class D3D9RenderWindow; 84 class D3D9Texture; 85 class D3D9TextureManager; 86 class D3D9Driver; 87 class D3D9DriverList; 88 class D3D9VideoMode; 89 class D3D9VideoModeList; 90 class D3D9GpuProgram; 91 class D3D9GpuProgramManager; 92 class D3D9HardwareBufferManager; 93 class D3D9HardwareIndexBuffer; 94 class D3D9HLSLProgramFactory; 95 class D3D9HLSLProgram; 96 class D3D9VertexDeclaration; 97 class D3D9Resource; 98 99 typedef SharedPtr<D3D9GpuProgram> D3D9GpuProgramPtr; 100 typedef SharedPtr<D3D9HLSLProgram> D3D9HLSLProgramPtr; 101 typedef SharedPtr<D3D9Texture> D3D9TexturePtr; 102 103 // Should we ask D3D to manage vertex/index buffers automatically? 104 // Doing so avoids lost devices, but also has a performance impact 105 // which is unacceptably bad when using very large buffers 106 #define OGRE_D3D_MANAGE_BUFFERS 1 107 108 //------------------------------------------- 109 // Windows setttings 110 //------------------------------------------- 111 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(OGRE_STATIC_LIB) 112 # ifdef OGRED3DENGINEDLL_EXPORTS 113 # define _OgreD3D9Export __declspec(dllexport) 114 # else 115 # if defined( __MINGW32__ ) 116 # define _OgreD3D9Export 117 # else 118 # define _OgreD3D9Export __declspec(dllimport) 119 # endif 120 # endif 121 #else 122 # define _OgreD3D9Export 123 #endif // OGRE_WIN32 124 } 125 #endif 126