forked from teamnwah/openmw-tes3coop
integrated video settings in the settings file, the launcher is now useless
This commit is contained in:
parent
7938566004
commit
343bbaf0fd
6 changed files with 216 additions and 212 deletions
|
@ -268,15 +268,6 @@ void OMW::Engine::go()
|
|||
|
||||
mOgre = new OEngine::Render::OgreRenderer;
|
||||
|
||||
//we need to ensure the path to the configuration exists before creating an
|
||||
//instance of ogre root so that Ogre doesn't raise an exception when trying to
|
||||
//access it
|
||||
const boost::filesystem::path configPath = mCfgMgr.getOgreConfigPath().parent_path();
|
||||
if ( !boost::filesystem::exists(configPath) )
|
||||
{
|
||||
boost::filesystem::create_directories(configPath);
|
||||
}
|
||||
|
||||
// Create the settings manager and load default settings file
|
||||
Settings::Manager settings;
|
||||
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg";
|
||||
|
@ -308,10 +299,20 @@ void OMW::Engine::go()
|
|||
else if (boost::filesystem::exists(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg"))
|
||||
nifOverrides.loadTransparencyOverrides(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg");
|
||||
|
||||
mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()),
|
||||
mCfgMgr.getOgreConfigPath().string(),
|
||||
std::string renderSystem = settings.getString("render system", "Video");
|
||||
if (renderSystem == "")
|
||||
{
|
||||
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
|
||||
renderSystem = "Direct3D9 Rendering Subsystem";
|
||||
#else
|
||||
renderSystem = "OpenGL Rendering Subsystem";
|
||||
#endif
|
||||
}
|
||||
mOgre->configure(
|
||||
mCfgMgr.getLogPath().string(),
|
||||
mCfgMgr.getPluginsConfigPath().string(), false);
|
||||
mCfgMgr.getPluginsConfigPath().string(),
|
||||
renderSystem,
|
||||
false);
|
||||
|
||||
// This has to be added BEFORE MyGUI is initialized, as it needs
|
||||
// to find core.xml here.
|
||||
|
@ -325,7 +326,14 @@ void OMW::Engine::go()
|
|||
addZipResource(mResDir / "mygui" / "Obliviontt.zip");
|
||||
|
||||
// Create the window
|
||||
mOgre->createWindow("OpenMW");
|
||||
OEngine::Render::WindowSettings windowSettings;
|
||||
windowSettings.fullscreen = settings.getBool("fullscreen", "Video");
|
||||
windowSettings.window_x = settings.getInt("resolution x", "Video");
|
||||
windowSettings.window_y = settings.getInt("resolution y", "Video");
|
||||
windowSettings.vsync = settings.getBool("vsync", "Video");
|
||||
std::string aa = settings.getString("antialiasing", "Video");
|
||||
windowSettings.fsaa = (aa.substr(0, 4) == "MSAA") ? aa.substr(5, aa.size()-5) : "0";
|
||||
mOgre->createWindow("OpenMW", windowSettings);
|
||||
|
||||
loadBSA();
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace Files
|
|||
{
|
||||
|
||||
static const char* const openmwCfgFile = "openmw.cfg";
|
||||
static const char* const ogreCfgFile = "ogre.cfg";
|
||||
static const char* const pluginsCfgFile = "plugins.cfg";
|
||||
|
||||
const char* const mwToken = "?mw?";
|
||||
|
@ -39,7 +38,6 @@ ConfigurationManager::ConfigurationManager()
|
|||
}
|
||||
}
|
||||
|
||||
mOgreCfgPath = mFixedPath.getUserPath() / ogreCfgFile;
|
||||
mLogPath = mFixedPath.getUserPath();
|
||||
}
|
||||
|
||||
|
@ -164,11 +162,6 @@ const boost::filesystem::path& ConfigurationManager::getInstallPath() const
|
|||
return mFixedPath.getInstallPath();
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getOgreConfigPath() const
|
||||
{
|
||||
return mOgreCfgPath;
|
||||
}
|
||||
|
||||
const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const
|
||||
{
|
||||
return mPluginsCfgPath;
|
||||
|
|
|
@ -41,7 +41,6 @@ struct ConfigurationManager
|
|||
const boost::filesystem::path& getLocalDataPath() const;
|
||||
const boost::filesystem::path& getInstallPath() const;
|
||||
|
||||
const boost::filesystem::path& getOgreConfigPath() const;
|
||||
const boost::filesystem::path& getPluginsConfigPath() const;
|
||||
const boost::filesystem::path& getLogPath() const;
|
||||
|
||||
|
@ -59,7 +58,6 @@ struct ConfigurationManager
|
|||
|
||||
FixedPathType mFixedPath;
|
||||
|
||||
boost::filesystem::path mOgreCfgPath;
|
||||
boost::filesystem::path mPluginsCfgPath;
|
||||
boost::filesystem::path mLogPath;
|
||||
|
||||
|
|
|
@ -1,6 +1,29 @@
|
|||
# WARNING: Editing this file might have no effect, as these
|
||||
# settings are overwritten by your user settings file.
|
||||
|
||||
[Video]
|
||||
resolution x = 800
|
||||
resolution y = 600
|
||||
|
||||
fullscreen = false
|
||||
|
||||
# Render system
|
||||
# blank means default
|
||||
# Valid values:
|
||||
# OpenGL Rendering Subsystem
|
||||
# Direct3D9 Rendering Subsystem
|
||||
render system =
|
||||
|
||||
# Valid values:
|
||||
# none
|
||||
# MSAA 2
|
||||
# MSAA 4
|
||||
# MSAA 8
|
||||
# MSAA 16
|
||||
antialiasing = none
|
||||
|
||||
vsync = false
|
||||
|
||||
[General]
|
||||
# Camera field of view
|
||||
field of view = 55
|
||||
|
|
|
@ -13,17 +13,17 @@ using namespace OEngine::Render;
|
|||
|
||||
void OgreRenderer::cleanup()
|
||||
{
|
||||
if (mFader)
|
||||
delete mFader;
|
||||
|
||||
if(mRoot)
|
||||
delete mRoot;
|
||||
mRoot = NULL;
|
||||
if (mFader)
|
||||
delete mFader;
|
||||
|
||||
if(mRoot)
|
||||
delete mRoot;
|
||||
mRoot = NULL;
|
||||
}
|
||||
|
||||
void OgreRenderer::start()
|
||||
{
|
||||
mRoot->startRendering();
|
||||
mRoot->startRendering();
|
||||
}
|
||||
|
||||
bool OgreRenderer::loadPlugins()
|
||||
|
@ -53,96 +53,79 @@ bool OgreRenderer::loadPlugins()
|
|||
|
||||
void OgreRenderer::update(float dt)
|
||||
{
|
||||
mFader->update(dt);
|
||||
mFader->update(dt);
|
||||
}
|
||||
|
||||
void OgreRenderer::screenshot(const std::string &file)
|
||||
{
|
||||
mWindow->writeContentsToFile(file);
|
||||
mWindow->writeContentsToFile(file);
|
||||
}
|
||||
|
||||
float OgreRenderer::getFPS()
|
||||
{
|
||||
return mWindow->getLastFPS();
|
||||
return mWindow->getLastFPS();
|
||||
}
|
||||
|
||||
bool OgreRenderer::configure(bool showConfig,
|
||||
const std::string &cfgPath,
|
||||
const std::string &logPath,
|
||||
const std::string &pluginCfg,
|
||||
bool _logging)
|
||||
void OgreRenderer::configure(const std::string &logPath,
|
||||
const std::string &pluginCfg,
|
||||
const std::string& renderSystem,
|
||||
bool _logging)
|
||||
{
|
||||
// Set up logging first
|
||||
new LogManager;
|
||||
Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
|
||||
logging = _logging;
|
||||
// Set up logging first
|
||||
new LogManager;
|
||||
Log *log = LogManager::getSingleton().createLog(logPath + std::string("Ogre.log"));
|
||||
logging = _logging;
|
||||
|
||||
if(logging)
|
||||
// Full log detail
|
||||
log->setLogDetail(LL_BOREME);
|
||||
else
|
||||
// Disable logging
|
||||
log->setDebugOutputEnabled(false);
|
||||
if(logging)
|
||||
// Full log detail
|
||||
log->setLogDetail(LL_BOREME);
|
||||
else
|
||||
// Disable logging
|
||||
log->setDebugOutputEnabled(false);
|
||||
|
||||
#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, "");
|
||||
loadPlugins();
|
||||
#else
|
||||
mRoot = new Root(pluginCfg, cfgPath, "");
|
||||
#endif
|
||||
#if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX)
|
||||
mRoot = new Root("", "", "");
|
||||
loadPlugins();
|
||||
#else
|
||||
mRoot = new Root(pluginCfg, "", "");
|
||||
#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;
|
||||
RenderSystem* rs = mRoot->getRenderSystemByName(renderSystem);
|
||||
if (rs == 0)
|
||||
throw std::runtime_error ("RenderSystem with name " + renderSystem + " not found, make sure the plugins are loaded");
|
||||
mRoot->setRenderSystem(rs);
|
||||
}
|
||||
|
||||
bool OgreRenderer::configure(bool showConfig,
|
||||
const std::string &cfgPath,
|
||||
const std::string &pluginCfg,
|
||||
bool _logging)
|
||||
void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings)
|
||||
{
|
||||
return configure(showConfig, cfgPath, cfgPath, pluginCfg, _logging);
|
||||
}
|
||||
assert(mRoot);
|
||||
mRoot->initialise(false);
|
||||
|
||||
bool OgreRenderer::configure(bool showConfig,
|
||||
const std::string &pluginCfg,
|
||||
bool _logging)
|
||||
{
|
||||
return configure(showConfig, "", pluginCfg, _logging);
|
||||
}
|
||||
NameValuePairList params;
|
||||
params.insert(std::make_pair("title", title));
|
||||
params.insert(std::make_pair("FSAA", settings.fsaa));
|
||||
params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false"));
|
||||
|
||||
void OgreRenderer::createWindow(const std::string &title)
|
||||
{
|
||||
assert(mRoot);
|
||||
// Initialize OGRE window
|
||||
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)
|
||||
{
|
||||
assert(mRoot);
|
||||
assert(mWindow);
|
||||
// Get the SceneManager, in this case a generic one
|
||||
mScene = mRoot->createSceneManager(ST_GENERIC);
|
||||
assert(mRoot);
|
||||
assert(mWindow);
|
||||
// Get the SceneManager, in this case a generic one
|
||||
mScene = mRoot->createSceneManager(ST_GENERIC);
|
||||
|
||||
// Create the camera
|
||||
mCamera = mScene->createCamera(camName);
|
||||
mCamera->setNearClipDistance(nearClip);
|
||||
mCamera->setFOVy(Degree(fov));
|
||||
// Create the camera
|
||||
mCamera = mScene->createCamera(camName);
|
||||
mCamera->setNearClipDistance(nearClip);
|
||||
mCamera->setFOVy(Degree(fov));
|
||||
|
||||
// Create one viewport, entire window
|
||||
mView = mWindow->addViewport(mCamera);
|
||||
// Create one viewport, entire window
|
||||
mView = mWindow->addViewport(mCamera);
|
||||
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
|
||||
mFader = new Fader();
|
||||
// Alter the camera aspect ratio to match the viewport
|
||||
mCamera->setAspectRatio(Real(mView->getActualWidth()) / Real(mView->getActualHeight()));
|
||||
|
||||
mFader = new Fader();
|
||||
}
|
||||
|
|
|
@ -33,124 +33,123 @@ namespace Ogre
|
|||
class Viewport;
|
||||
}
|
||||
|
||||
namespace OEngine {
|
||||
namespace Render
|
||||
namespace OEngine
|
||||
{
|
||||
class Fader;
|
||||
class OgreRenderer
|
||||
{
|
||||
Ogre::Root *mRoot;
|
||||
Ogre::RenderWindow *mWindow;
|
||||
Ogre::SceneManager *mScene;
|
||||
Ogre::Camera *mCamera;
|
||||
Ogre::Viewport *mView;
|
||||
#ifdef ENABLE_PLUGIN_CgProgramManager
|
||||
Ogre::CgPlugin* mCgPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_OctreeSceneManager
|
||||
Ogre::OctreePlugin* mOctreePlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_ParticleFX
|
||||
Ogre::ParticleFXPlugin* mParticleFXPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
Ogre::GLPlugin* mGLPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||
#endif
|
||||
Fader* mFader;
|
||||
bool logging;
|
||||
|
||||
public:
|
||||
OgreRenderer()
|
||||
: mRoot(NULL)
|
||||
, mWindow(NULL)
|
||||
, mScene(NULL)
|
||||
, mCamera(NULL)
|
||||
, mView(NULL)
|
||||
#ifdef ENABLE_PLUGIN_CgProgramManager
|
||||
, mCgPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_OctreeSceneManager
|
||||
, mOctreePlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_ParticleFX
|
||||
, mParticleFXPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
, mGLPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||
, mD3D9Plugin(NULL)
|
||||
#endif
|
||||
, mFader(NULL)
|
||||
, logging(false)
|
||||
namespace Render
|
||||
{
|
||||
struct WindowSettings
|
||||
{
|
||||
bool vsync;
|
||||
bool fullscreen;
|
||||
int window_x, window_y;
|
||||
std::string fsaa;
|
||||
};
|
||||
|
||||
class Fader;
|
||||
class OgreRenderer
|
||||
{
|
||||
Ogre::Root *mRoot;
|
||||
Ogre::RenderWindow *mWindow;
|
||||
Ogre::SceneManager *mScene;
|
||||
Ogre::Camera *mCamera;
|
||||
Ogre::Viewport *mView;
|
||||
#ifdef ENABLE_PLUGIN_CgProgramManager
|
||||
Ogre::CgPlugin* mCgPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_OctreeSceneManager
|
||||
Ogre::OctreePlugin* mOctreePlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_ParticleFX
|
||||
Ogre::ParticleFXPlugin* mParticleFXPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
Ogre::GLPlugin* mGLPlugin;
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||
Ogre::D3D9Plugin* mD3D9Plugin;
|
||||
#endif
|
||||
Fader* mFader;
|
||||
bool logging;
|
||||
|
||||
public:
|
||||
OgreRenderer()
|
||||
: mRoot(NULL)
|
||||
, mWindow(NULL)
|
||||
, mScene(NULL)
|
||||
, mCamera(NULL)
|
||||
, mView(NULL)
|
||||
#ifdef ENABLE_PLUGIN_CgProgramManager
|
||||
, mCgPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_OctreeSceneManager
|
||||
, mOctreePlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_ParticleFX
|
||||
, mParticleFXPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_GL
|
||||
, mGLPlugin(NULL)
|
||||
#endif
|
||||
#ifdef ENABLE_PLUGIN_Direct3D9
|
||||
, mD3D9Plugin(NULL)
|
||||
#endif
|
||||
, mFader(NULL)
|
||||
, logging(false)
|
||||
{
|
||||
}
|
||||
|
||||
~OgreRenderer() { cleanup(); }
|
||||
|
||||
/** Configure the renderer. This will load configuration files and
|
||||
set up the Root and logging classes. */
|
||||
void configure(
|
||||
const std::string &logPath, // Path to directory where to store log files
|
||||
const std::string &pluginCfg, // plugin.cfg file
|
||||
const std::string &renderSystem,
|
||||
bool _logging); // Enable or disable logging
|
||||
|
||||
/// Create a window with the given title
|
||||
void createWindow(const std::string &title, const WindowSettings& settings);
|
||||
|
||||
/// Set up the scene manager, camera and viewport
|
||||
void createScene(const std::string camName="Camera",// Camera name
|
||||
float fov=55, // Field of view angle
|
||||
float nearClip=5 // Near clip distance
|
||||
);
|
||||
|
||||
/// Kill the renderer.
|
||||
void cleanup();
|
||||
|
||||
/// Start the main rendering loop
|
||||
void start();
|
||||
|
||||
bool loadPlugins();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
/// Write a screenshot to file
|
||||
void screenshot(const std::string &file);
|
||||
|
||||
float getFPS();
|
||||
|
||||
/// Get the Root
|
||||
Ogre::Root *getRoot() { return mRoot; }
|
||||
|
||||
/// Get the rendering window
|
||||
Ogre::RenderWindow *getWindow() { return mWindow; }
|
||||
|
||||
/// Get the scene manager
|
||||
Ogre::SceneManager *getScene() { return mScene; }
|
||||
|
||||
/// Get the screen colour fader
|
||||
Fader *getFader() { return mFader; }
|
||||
|
||||
/// Camera
|
||||
Ogre::Camera *getCamera() { return mCamera; }
|
||||
|
||||
/// Viewport
|
||||
Ogre::Viewport *getViewport() { return mView; }
|
||||
};
|
||||
}
|
||||
|
||||
~OgreRenderer() { cleanup(); }
|
||||
|
||||
/** Configure the renderer. This will load configuration files and
|
||||
set up the Root and logging classes. */
|
||||
bool configure(bool showConfig, // Show config dialog box?
|
||||
const std::string &cfgPath, // Path to directory where to store config files
|
||||
const std::string &logPath, // Path to directory where to store log files
|
||||
const std::string &pluginCfg, // plugin.cfg file
|
||||
bool _logging); // Enable or disable logging
|
||||
|
||||
bool configure(bool showConfig, // Show config dialog box?
|
||||
const std::string &cfgPath, // Path to directory where to store config files
|
||||
const std::string &pluginCfg, // plugin.cfg file
|
||||
bool _logging); // Enable or disable logging
|
||||
|
||||
/** Configure the renderer. This will load configuration files and
|
||||
set up the Root and logging classes. */
|
||||
bool configure(bool showConfig, // Show config dialog box?
|
||||
const std::string &pluginCfg, // plugin.cfg file
|
||||
bool _logging); // Enable or disable logging
|
||||
|
||||
/// Create a window with the given title
|
||||
void createWindow(const std::string &title);
|
||||
|
||||
/// Set up the scene manager, camera and viewport
|
||||
void createScene(const std::string camName="Camera",// Camera name
|
||||
float fov=55, // Field of view angle
|
||||
float nearClip=5 // Near clip distance
|
||||
);
|
||||
|
||||
/// Kill the renderer.
|
||||
void cleanup();
|
||||
|
||||
/// Start the main rendering loop
|
||||
void start();
|
||||
|
||||
bool loadPlugins();
|
||||
|
||||
void update(float dt);
|
||||
|
||||
/// Write a screenshot to file
|
||||
void screenshot(const std::string &file);
|
||||
|
||||
float getFPS();
|
||||
|
||||
/// Get the Root
|
||||
Ogre::Root *getRoot() { return mRoot; }
|
||||
|
||||
/// Get the rendering window
|
||||
Ogre::RenderWindow *getWindow() { return mWindow; }
|
||||
|
||||
/// Get the scene manager
|
||||
Ogre::SceneManager *getScene() { return mScene; }
|
||||
|
||||
/// Get the screen colour fader
|
||||
Fader *getFader() { return mFader; }
|
||||
|
||||
/// Camera
|
||||
Ogre::Camera *getCamera() { return mCamera; }
|
||||
|
||||
/// Viewport
|
||||
Ogre::Viewport *getViewport() { return mView; }
|
||||
};
|
||||
}}
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue