1 | |
---|
2 | #include "OBAOgreBase.h" |
---|
3 | |
---|
4 | namespace OBA { |
---|
5 | |
---|
6 | template <> OgreBase* CSingleton<OgreBase>::ms_Singleton = NULL; |
---|
7 | |
---|
8 | OgreBase* OgreBase::getSingletonPtr(void) |
---|
9 | { |
---|
10 | return ms_Singleton; |
---|
11 | } |
---|
12 | |
---|
13 | OgreBase& OgreBase::getSingleton(void) |
---|
14 | { |
---|
15 | assert( ms_Singleton ); return ( *ms_Singleton ); |
---|
16 | } |
---|
17 | |
---|
18 | OgreBase::OgreBase() |
---|
19 | { |
---|
20 | } |
---|
21 | |
---|
22 | OgreBase::~OgreBase() |
---|
23 | { |
---|
24 | |
---|
25 | } |
---|
26 | |
---|
27 | Ogre::XMLMeshSerializer* OgreBase::getXMLMeshSerializer() |
---|
28 | { |
---|
29 | return mXMLMeshSerializer; |
---|
30 | } |
---|
31 | |
---|
32 | Ogre::MaterialSerializer* OgreBase::getMaterialSerializer() |
---|
33 | { |
---|
34 | return mMaterialSerializer; |
---|
35 | } |
---|
36 | |
---|
37 | Ogre::MeshSerializer* OgreBase::getMeshSerializer() |
---|
38 | { |
---|
39 | return mMeshSerializer; |
---|
40 | } |
---|
41 | |
---|
42 | void OgreBase::initialize() |
---|
43 | { |
---|
44 | mLogManager = new Ogre::LogManager();
|
---|
45 | mLogManager->createLog("Ogre.log", true, true); |
---|
46 | mArchiveManager = new Ogre::ArchiveManager();
|
---|
47 | mResourceGroupManager = new Ogre::ResourceGroupManager(); |
---|
48 | mMath = new Ogre::Math(); |
---|
49 | mMeshManager = new Ogre::MeshManager(); |
---|
50 | mMaterialManager = new Ogre::MaterialManager(); |
---|
51 | mMaterialManager->initialise(); |
---|
52 | mMaterialSerializer = new Ogre::MaterialSerializer(); |
---|
53 | mMeshSerializer = new Ogre::MeshSerializer(); |
---|
54 | mXMLMeshSerializer = new Ogre::XMLMeshSerializer(); |
---|
55 | mFileSystemArchiveFactory = new FileSystemArchiveFactory();
|
---|
56 | Ogre::ArchiveManager::getSingleton().addArchiveFactory( mFileSystemArchiveFactory );
|
---|
57 | mDefaultHardwareBufferManager = new Ogre::DefaultHardwareBufferManager(); |
---|
58 | } |
---|
59 | |
---|
60 | void OgreBase::shutdown() |
---|
61 | { |
---|
62 | |
---|
63 | if (mArchiveManager) |
---|
64 | { |
---|
65 | delete mArchiveManager;
|
---|
66 | }
|
---|
67 |
|
---|
68 | if (mFileSystemArchiveFactory)
|
---|
69 | {
|
---|
70 | delete mFileSystemArchiveFactory;
|
---|
71 | } |
---|
72 | |
---|
73 | if (mMeshSerializer) |
---|
74 | { |
---|
75 | delete mMeshSerializer; |
---|
76 | } |
---|
77 | |
---|
78 | if (mXMLMeshSerializer) |
---|
79 | { |
---|
80 | delete mXMLMeshSerializer; |
---|
81 | } |
---|
82 | |
---|
83 | if (mMaterialSerializer) |
---|
84 | { |
---|
85 | delete mMaterialSerializer; |
---|
86 | } |
---|
87 | |
---|
88 | if (mMath) |
---|
89 | { |
---|
90 | delete mMath; |
---|
91 | } |
---|
92 | |
---|
93 | if (mMeshManager)
|
---|
94 | {
|
---|
95 | delete mMeshManager;
|
---|
96 | } |
---|
97 | |
---|
98 | if (mMaterialManager) |
---|
99 | { |
---|
100 | mMaterialManager->removeAll(); |
---|
101 | delete mMaterialManager; |
---|
102 | } |
---|
103 | |
---|
104 | if (mResourceGroupManager)
|
---|
105 | {
|
---|
106 | delete mResourceGroupManager;
|
---|
107 | } |
---|
108 | |
---|
109 | // Not necessary if we have a RenderWindow... |
---|
110 | if (mDefaultHardwareBufferManager) |
---|
111 | { |
---|
112 | delete mDefaultHardwareBufferManager; |
---|
113 | } |
---|
114 | |
---|
115 | if (mLogManager)
|
---|
116 | {
|
---|
117 | delete mLogManager;
|
---|
118 | } |
---|
119 | } |
---|
120 | |
---|
121 | } |
---|