|
|
@ -13,17 +13,17 @@ using namespace OEngine::Render;
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::cleanup()
|
|
|
|
void OgreRenderer::cleanup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (mFader)
|
|
|
|
if (mFader)
|
|
|
|
delete mFader;
|
|
|
|
delete mFader;
|
|
|
|
|
|
|
|
|
|
|
|
if(mRoot)
|
|
|
|
if(mRoot)
|
|
|
|
delete mRoot;
|
|
|
|
delete mRoot;
|
|
|
|
mRoot = NULL;
|
|
|
|
mRoot = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::start()
|
|
|
|
void OgreRenderer::start()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mRoot->startRendering();
|
|
|
|
mRoot->startRendering();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OgreRenderer::loadPlugins()
|
|
|
|
bool OgreRenderer::loadPlugins()
|
|
|
@ -53,96 +53,79 @@ bool OgreRenderer::loadPlugins()
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::update(float dt)
|
|
|
|
void OgreRenderer::update(float dt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mFader->update(dt);
|
|
|
|
mFader->update(dt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::screenshot(const std::string &file)
|
|
|
|
void OgreRenderer::screenshot(const std::string &file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mWindow->writeContentsToFile(file);
|
|
|
|
mWindow->writeContentsToFile(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float OgreRenderer::getFPS()
|
|
|
|
float OgreRenderer::getFPS()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mWindow->getLastFPS();
|
|
|
|
return mWindow->getLastFPS();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OgreRenderer::configure(bool showConfig,
|
|
|
|
void OgreRenderer::configure(const std::string &logPath,
|
|
|
|
const std::string &cfgPath,
|
|
|
|
const std::string &pluginCfg,
|
|
|
|
const std::string &logPath,
|
|
|
|
const std::string& renderSystem,
|
|
|
|
const std::string &pluginCfg,
|
|
|
|
bool _logging)
|
|
|
|
bool _logging)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Set up logging first
|
|
|
|
// Set up logging first
|
|
|
|
new LogManager;
|
|
|
|
new LogManager;
|
|
|
|
Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
|
|
|
|
Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
|
|
|
|
logging = _logging;
|
|
|
|
logging = _logging;
|
|
|
|
|
|
|
|
|
|
|
|
if(logging)
|
|
|
|
if(logging)
|
|
|
|
// Full log detail
|
|
|
|
// Full log detail
|
|
|
|
log->setLogDetail(LL_BOREME);
|
|
|
|
log->setLogDetail(LL_BOREME);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
// Disable logging
|
|
|
|
// Disable logging
|
|
|
|
log->setDebugOutputEnabled(false);
|
|
|
|
log->setDebugOutputEnabled(false);
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
|
|
|
|
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
|
|
|
|
mRoot = new Root("", cfgPath, "");
|
|
|
|
mRoot = new Root("", "", "");
|
|
|
|
loadPlugins();
|
|
|
|
loadPlugins();
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
mRoot = new Root(pluginCfg, cfgPath, "");
|
|
|
|
mRoot = new Root(pluginCfg, "", "");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
// Show the configuration dialog and initialise the system, if the
|
|
|
|
|
|
|
|
// showConfig parameter is specified. The settings are stored in
|
|
|
|
|
|
|
|
// ogre.cfg. If showConfig is false, the settings are assumed to
|
|
|
|
|
|
|
|
// already exist in ogre.cfg.
|
|
|
|
|
|
|
|
int result;
|
|
|
|
|
|
|
|
if(showConfig)
|
|
|
|
|
|
|
|
result = mRoot->showConfigDialog();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
result = mRoot->restoreConfig();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool OgreRenderer::configure(bool showConfig,
|
|
|
|
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
|
|
|
|
const std::string &cfgPath,
|
|
|
|
if (rs == 0)
|
|
|
|
const std::string &pluginCfg,
|
|
|
|
throw std::runtime_error ("RenderSystem with name " + renderSystem + " not found, make sure the plugins are loaded");
|
|
|
|
bool _logging)
|
|
|
|
mRoot->setRenderSystem(rs);
|
|
|
|
{
|
|
|
|
|
|
|
|
return configure(showConfig, cfgPath, cfgPath, pluginCfg, _logging);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool OgreRenderer::configure(bool showConfig,
|
|
|
|
void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings)
|
|
|
|
const std::string &pluginCfg,
|
|
|
|
|
|
|
|
bool _logging)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return configure(showConfig, "", pluginCfg, _logging);
|
|
|
|
assert(mRoot);
|
|
|
|
}
|
|
|
|
mRoot->initialise(false);
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::createWindow(const std::string &title)
|
|
|
|
NameValuePairList params;
|
|
|
|
{
|
|
|
|
params.insert(std::make_pair("title", title));
|
|
|
|
assert(mRoot);
|
|
|
|
params.insert(std::make_pair("FSAA", settings.fsaa));
|
|
|
|
// Initialize OGRE window
|
|
|
|
params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false"));
|
|
|
|
mWindow = mRoot->initialise(true, title, "");
|
|
|
|
|
|
|
|
|
|
|
|
mWindow = mRoot->createRenderWindow(title, settings.window_x, settings.window_y, settings.fullscreen, ¶ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OgreRenderer::createScene(const std::string camName, float fov, float nearClip)
|
|
|
|
void OgreRenderer::createScene(const std::string camName, float fov, float nearClip)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert(mRoot);
|
|
|
|
assert(mRoot);
|
|
|
|
assert(mWindow);
|
|
|
|
assert(mWindow);
|
|
|
|
// Get the SceneManager, in this case a generic one
|
|
|
|
// Get the SceneManager, in this case a generic one
|
|
|
|
mScene = mRoot->createSceneManager(ST_GENERIC);
|
|
|
|
mScene = mRoot->createSceneManager(ST_GENERIC);
|
|
|
|
|
|
|
|
|
|
|
|
// Create the camera
|
|
|
|
// Create the camera
|
|
|
|
mCamera = mScene->createCamera(camName);
|
|
|
|
mCamera = mScene->createCamera(camName);
|
|
|
|
mCamera->setNearClipDistance(nearClip);
|
|
|
|
mCamera->setNearClipDistance(nearClip);
|
|
|
|
mCamera->setFOVy(Degree(fov));
|
|
|
|
mCamera->setFOVy(Degree(fov));
|
|
|
|
|
|
|
|
|
|
|
|
// Create one viewport, entire window
|
|
|
|
// Create one viewport, entire window
|
|
|
|
mView = mWindow->addViewport(mCamera);
|
|
|
|
mView = mWindow->addViewport(mCamera);
|
|
|
|
|
|
|
|
|
|
|
|
// Alter the camera aspect ratio to match the viewport
|
|
|
|
// Alter the camera aspect ratio to match the viewport
|
|
|
|
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
|
|
|
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
|
|
|
|
|
|
|
|
|
|
|
mFader = new Fader();
|
|
|
|
mFader = new Fader();
|
|
|
|
}
|
|
|
|
}
|
|
|
|