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-2014 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 __D3D11PREREQUISITES_H__ 29 #define __D3D11PREREQUISITES_H__ 30 31 32 33 #include "OgrePrerequisites.h" 34 #include "OgreMinGWSupport.h" // extra defines for MinGW to deal with DX SDK 35 #include "OgreComPtr.h" // too much resource leaks were caused without it by throwing constructors 36 37 #include "OgreException.h" 38 39 #ifdef OGRE_EXCEPT_EX 40 #undef OGRE_EXCEPT_EX 41 #endif 42 43 #define OGRE_EXCEPT_EX(code, num, desc, src) throw Ogre::D3D11RenderingAPIException(num, desc, src, __FILE__, __LINE__) 44 45 // some D3D commonly used macros 46 #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } 47 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } 48 #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } 49 50 #if defined(_WIN32_WINNT_WIN8) // Win8 SDK required to compile, will work on Windows 8 and Platform Update for Windows 7 51 #define OGRE_D3D11_PROFILING OGRE_PROFILING 52 #endif 53 54 #undef NOMINMAX 55 #define NOMINMAX // required to stop windows.h screwing up std::min definition 56 #if OGRE_PLATFORM == OGRE_PLATFORM_WINRT || OGRE_D3D11_PROFILING 57 #include <d3d11_1.h> 58 #else 59 #include <d3d11.h> 60 #endif 61 62 #if __OGRE_WINRT_PHONE_80 63 # include <C:\Program Files (x86)\Windows Kits\8.0\Include\um\d3d11shader.h> 64 #else 65 # include <d3d11shader.h> 66 # include <d3dcompiler.h> 67 #endif 68 69 70 namespace Ogre 71 { 72 // typedefs to work with Direct3D 11 or 11.1 as appropriate 73 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 74 typedef ID3D11Device ID3D11DeviceN; 75 typedef ID3D11DeviceContext ID3D11DeviceContextN; 76 typedef ID3D11RasterizerState ID3D11RasterizerStateN; 77 typedef IDXGIFactory1 IDXGIFactoryN; 78 typedef IDXGIAdapter1 IDXGIAdapterN; 79 typedef IDXGIDevice1 IDXGIDeviceN; 80 typedef IDXGISwapChain IDXGISwapChainN; 81 typedef DXGI_SWAP_CHAIN_DESC DXGI_SWAP_CHAIN_DESC_N; 82 #elif OGRE_PLATFORM == OGRE_PLATFORM_WINRT 83 typedef ID3D11Device1 ID3D11DeviceN; 84 typedef ID3D11DeviceContext1 ID3D11DeviceContextN; 85 typedef ID3D11RasterizerState1 ID3D11RasterizerStateN; 86 typedef IDXGIFactory2 IDXGIFactoryN; 87 typedef IDXGIAdapter1 IDXGIAdapterN; // we don`t need IDXGIAdapter2 functionality 88 typedef IDXGIDevice2 IDXGIDeviceN; 89 typedef IDXGISwapChain1 IDXGISwapChainN; 90 typedef DXGI_SWAP_CHAIN_DESC1 DXGI_SWAP_CHAIN_DESC_N; 91 #endif 92 93 // Predefine classes 94 class D3D11RenderSystem; 95 class D3D11RenderWindowBase; 96 class D3D11Texture; 97 class D3D11TextureManager; 98 class D3D11DepthBuffer; 99 class D3D11Driver; 100 class D3D11DriverList; 101 class D3D11VideoMode; 102 class D3D11VideoModeList; 103 class D3D11GpuProgramManager; 104 class D3D11HardwareBufferManager; 105 class D3D11HardwareIndexBuffer; 106 class D3D11HLSLProgramFactory; 107 class D3D11HLSLProgram; 108 class D3D11VertexDeclaration; 109 class D3D11Device; 110 class D3D11HardwareBuffer; 111 class D3D11HardwarePixelBuffer; 112 113 typedef SharedPtr<D3D11HLSLProgram> D3D11HLSLProgramPtr; 114 typedef SharedPtr<D3D11Texture> D3D11TexturePtr; 115 116 //------------------------------------------- 117 // Windows setttings 118 //------------------------------------------- 119 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT) && !defined(OGRE_STATIC_LIB) 120 # ifdef OGRED3DENGINEDLL_EXPORTS 121 # define _OgreD3D11Export __declspec(dllexport) 122 # else 123 # if defined( __MINGW32__ ) 124 # define _OgreD3D11Export 125 # else 126 # define _OgreD3D11Export __declspec(dllimport) 127 # endif 128 # endif 129 #else 130 # define _OgreD3D11Export 131 #endif // OGRE_WIN32 132 133 class _OgreD3D11Export D3D11RenderingAPIException : public RenderingAPIException 134 { 135 int hresult; 136 public: D3D11RenderingAPIException(int hr,const String & inDescription,const String & inSource,const char * inFile,long inLine)137 D3D11RenderingAPIException(int hr, const String& inDescription, const String& inSource, const char* inFile, long inLine) 138 : RenderingAPIException(hr, inDescription, inSource, inFile, inLine), hresult(hr) {} 139 getHResult()140 int getHResult() const { return hresult; } 141 getFullDescription(void)142 const String& getFullDescription(void) const { 143 StringStream ss(RenderingAPIException::getFullDescription()); 144 ss << " HRESULT=" << hresult; 145 fullDesc = ss.str(); 146 return fullDesc; 147 } 148 }; 149 } 150 #endif 151