OGRE  1.8
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9Prerequisites.h
Go to the documentation of this file.
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 #if OGRE_THREAD_SUPPORT
37 #define OGRE_LOCK_RECURSIVE_MUTEX(name) name.lock();
38 #define OGRE_UNLOCK_RECURSIVE_MUTEX(name) name.unlock();
39 #else
40 #define OGRE_LOCK_RECURSIVE_MUTEX(name)
41 #define OGRE_UNLOCK_RECURSIVE_MUTEX(name)
42 #endif
43 
44 
45 #if OGRE_THREAD_SUPPORT == 1
46 #define D3D9_DEVICE_ACCESS_LOCK OGRE_LOCK_RECURSIVE_MUTEX(msDeviceAccessMutex);
47 #define D3D9_DEVICE_ACCESS_UNLOCK OGRE_UNLOCK_RECURSIVE_MUTEX(msDeviceAccessMutex);
48 #define D3D9_DEVICE_ACCESS_CRITICAL_SECTION OGRE_LOCK_MUTEX(msDeviceAccessMutex)
49 #else
50 #define D3D9_DEVICE_ACCESS_LOCK
51 #define D3D9_DEVICE_ACCESS_UNLOCK
52 #define D3D9_DEVICE_ACCESS_CRITICAL_SECTION
53 #endif
54 
55 // Define versions for if DirectX is in use (Win32 only)
56 #define DIRECT3D_VERSION 0x0900
57 
58 // some D3D commonly used macros
59 #define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
60 #define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
61 #define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
62 
63 // enable extended d3d debug
64 #if OGRE_DEBUG_MODE
65 # define D3D_DEBUG_INFO
66 #endif
67 
68 #define WIN32_LEAN_AND_MEAN
69 #if !defined(NOMINMAX) && defined(_MSC_VER)
70 # define NOMINMAX // required to stop windows.h messing up std::min
71 #endif
72 #include <d3d9.h>
73 #include <d3dx9.h>
74 #include <DxErr.h>
75 
76 
77 namespace Ogre
78 {
79  // Predefine classes
80  class D3D9DepthBuffer;
81  class D3D9RenderSystem;
82  class D3D9RenderWindow;
83  class D3D9Texture;
84  class D3D9TextureManager;
85  class D3D9Driver;
86  class D3D9DriverList;
87  class D3D9VideoMode;
88  class D3D9VideoModeList;
89  class D3D9GpuProgram;
90  class D3D9GpuProgramManager;
91  class D3D9HardwareBufferManager;
92  class D3D9HardwareIndexBuffer;
93  class D3D9HLSLProgramFactory;
94  class D3D9HLSLProgram;
95  class D3D9VertexDeclaration;
96  class D3D9Resource;
97 
98 // Should we ask D3D to manage vertex/index buffers automatically?
99 // Doing so avoids lost devices, but also has a performance impact
100 // which is unacceptably bad when using very large buffers
101 #define OGRE_D3D_MANAGE_BUFFERS 1
102 
103  //-------------------------------------------
104  // Windows setttings
105  //-------------------------------------------
106 #if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(OGRE_STATIC_LIB)
107 # ifdef OGRED3DENGINEDLL_EXPORTS
108 # define _OgreD3D9Export __declspec(dllexport)
109 # else
110 # if defined( __MINGW32__ )
111 # define _OgreD3D9Export
112 # else
113 # define _OgreD3D9Export __declspec(dllimport)
114 # endif
115 # endif
116 #else
117 # define _OgreD3D9Export
118 #endif // OGRE_WIN32
119 }
120 #endif