OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreD3D9ResourceManager.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-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 __D3D9ResourceManager_H__
29 #define __D3D9ResourceManager_H__
30 
31 #include "OgreD3D9Prerequisites.h"
32 
33 namespace Ogre {
34 
36  {
37  // Creates the rendering resource on the current active device that needs it.
38  // This policy should be used when video memory consumption should be minimized but
39  // it might cause some performance issues when using loader resource thread since
40  // a resource that was not created on specified device will be created on demand during
41  // the rendering process and might cause the FPS to drop down.
43 
44  // Create the rendering resource on every existing device.
45  // This policy should be used when working intensively with a background loader thread.
46  // In that case when multiple devices exist, the resource will be created on each device
47  // and will be ready to use in the rendering thread.
48  // The draw back can be some video memory waste in case that each device render different
49  // scene and doesn't really need all the resources.
51  };
52 
54  {
55 
56  // Interface.
57  public:
58 
59  // Called immediately after the Direct3D device has been created.
60  void notifyOnDeviceCreate (IDirect3DDevice9* d3d9Device);
61 
62  // Called before the Direct3D device is going to be destroyed.
63  void notifyOnDeviceDestroy (IDirect3DDevice9* d3d9Device);
64 
65  // Called immediately after the Direct3D device has entered a lost state.
66  void notifyOnDeviceLost (IDirect3DDevice9* d3d9Device);
67 
68  // Called immediately after the Direct3D device has been reset.
69  void notifyOnDeviceReset (IDirect3DDevice9* d3d9Device);
70 
71  // Called when device state is changing. Access to any device should be locked.
72  // Relevant for multi thread application.
73  void lockDeviceAccess ();
74 
75  // Called when device state change completed. Access to any device is allowed.
76  // Relevant for multi thread application.
77  void unlockDeviceAccess ();
78 
81 
82  void setCreationPolicy (D3D9ResourceCreationPolicy creationPolicy);
83  D3D9ResourceCreationPolicy getCreationPolicy () const;
84 
92  void setAutoHardwareBufferManagement(bool autoManagement) { mAutoHardwareBufferManagement = autoManagement; }
93  bool getAutoHardwareBufferManagement() const { return mAutoHardwareBufferManagement; }
94 
95  // Friends.
96  protected:
97  friend class D3D9Resource;
98 
99  // Types.
100  protected:
102  typedef ResourceContainer::iterator ResourceContainerIterator;
103 
104  // Protected methods.
105  protected:
106 
107  // Called when new resource created.
108  void _notifyResourceCreated (D3D9Resource* pResource);
109 
110  // Called when resource is about to be destroyed.
111  void _notifyResourceDestroyed (D3D9Resource* pResource);
112 
113 
114  // Attributes.
115  protected:
116  OGRE_MUTEX(mResourcesMutex);
121  };
122 }
123 
124 #endif
#define OGRE_MUTEX(name)
D3D9ResourceCreationPolicy mResourceCreationPolicy
set< D3D9Resource * >::type ResourceContainer
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
#define _OgreD3D9Export
void setAutoHardwareBufferManagement(bool autoManagement)
Set/Get automatic hardware buffers management.
ResourceContainer::iterator ResourceContainerIterator
Represents a Direct3D rendering resource.