-
Notifications
You must be signed in to change notification settings - Fork 0
/
Engine.cpp
executable file
·101 lines (79 loc) · 2.56 KB
/
Engine.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include "stdafx.h"
#include "Engine.h"
CEngine::CEngine(void)
: m_Root(NULL)
{
TCHAR szPath[MAX_PATH];
CString ApplicationName = "SceneEditor.exe";
GetModuleFileName(NULL, szPath, MAX_PATH);
Ogre::ConfigFile OgreConfigFile;
CString ApplicationPath(szPath);
ApplicationPath = ApplicationPath.Left(ApplicationPath.GetLength() - ApplicationName.GetLength());
m_Root = new Ogre::Root("", "", Ogre::String(ApplicationPath + "SceneEditor.log"));
OgreConfigFile.load(Ogre::String(ApplicationPath + "ogre.cfg"), "\t:=", false);
Ogre::String RenderSystemName;
RenderSystemName = OgreConfigFile.getSetting("Render System");
if (RenderSystemName == "Direct3D9 Rendering Subsystem")
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_Direct3D9_d");
#else
m_Root->loadPlugin("RenderSystem_Direct3D9");
#endif
}
else
if(RenderSystemName == "OpenGL Rendering Subsystem")
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_GL_d");
#else
m_Root->loadPlugin("RenderSystem_GL");
#endif
}
else
{
#ifdef _DEBUG
m_Root->loadPlugin("RenderSystem_Direct3D9_d");
#else
m_Root->loadPlugin("RenderSystem_Direct3D9");
#endif
}
#ifdef _DEBUG
m_Root->loadPlugin("Plugin_ParticleFX_d");
#else
m_Root->loadPlugin("Plugin_ParticleFX");
#endif
Ogre::RenderSystemList RendersList = m_Root->getAvailableRenderers();
m_Root->setRenderSystem(RendersList[0]);
//
// Initialize the system, but don't create a render window.
//
// Load resource paths from config file
Ogre::ConfigFile cf;
Ogre::String ResourcePath = ApplicationPath + "resources_d.cfg";
cf.load(ResourcePath);
// Go through all sections & settings in the file
Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
Ogre::String secName, typeName, archName;
while (seci.hasMoreElements())
{
secName = seci.peekNextKey();
Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
Ogre::ConfigFile::SettingsMultiMap::iterator i;
for (i = settings->begin(); i != settings->end(); ++i)
{
typeName = i->first;
archName = i->second;
archName = Ogre::String(ApplicationPath) + archName;
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(archName, typeName, secName);
}
}
m_Root->initialise(false);
}
CEngine::~CEngine(void)
{
}
Ogre::Root* CEngine::GetRoot(void)
{
return m_Root;
}