integrated video settings in the settings file, the launcher is now useless

actorid
scrawl 13 years ago
parent 7938566004
commit 343bbaf0fd

@ -268,15 +268,6 @@ void OMW::Engine::go()
mOgre = new OEngine::Render::OgreRenderer; 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 // Create the settings manager and load default settings file
Settings::Manager settings; Settings::Manager settings;
const std::string localdefault = mCfgMgr.getLocalPath().string() + "/settings-default.cfg"; 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")) else if (boost::filesystem::exists(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg"))
nifOverrides.loadTransparencyOverrides(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg"); nifOverrides.loadTransparencyOverrides(mCfgMgr.getGlobalPath().string() + "/transparency-overrides.cfg");
mOgre->configure(!boost::filesystem::is_regular_file(mCfgMgr.getOgreConfigPath()), std::string renderSystem = settings.getString("render system", "Video");
mCfgMgr.getOgreConfigPath().string(), if (renderSystem == "")
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
renderSystem = "Direct3D9 Rendering Subsystem";
#else
renderSystem = "OpenGL Rendering Subsystem";
#endif
}
mOgre->configure(
mCfgMgr.getLogPath().string(), mCfgMgr.getLogPath().string(),
mCfgMgr.getPluginsConfigPath().string(), false); mCfgMgr.getPluginsConfigPath().string(),
renderSystem,
false);
// This has to be added BEFORE MyGUI is initialized, as it needs // This has to be added BEFORE MyGUI is initialized, as it needs
// to find core.xml here. // to find core.xml here.
@ -325,7 +326,14 @@ void OMW::Engine::go()
addZipResource(mResDir / "mygui" / "Obliviontt.zip"); addZipResource(mResDir / "mygui" / "Obliviontt.zip");
// Create the window // 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(); loadBSA();

@ -15,7 +15,6 @@ namespace Files
{ {
static const char* const openmwCfgFile = "openmw.cfg"; static const char* const openmwCfgFile = "openmw.cfg";
static const char* const ogreCfgFile = "ogre.cfg";
static const char* const pluginsCfgFile = "plugins.cfg"; static const char* const pluginsCfgFile = "plugins.cfg";
const char* const mwToken = "?mw?"; const char* const mwToken = "?mw?";
@ -39,7 +38,6 @@ ConfigurationManager::ConfigurationManager()
} }
} }
mOgreCfgPath = mFixedPath.getUserPath() / ogreCfgFile;
mLogPath = mFixedPath.getUserPath(); mLogPath = mFixedPath.getUserPath();
} }
@ -164,11 +162,6 @@ const boost::filesystem::path& ConfigurationManager::getInstallPath() const
return mFixedPath.getInstallPath(); return mFixedPath.getInstallPath();
} }
const boost::filesystem::path& ConfigurationManager::getOgreConfigPath() const
{
return mOgreCfgPath;
}
const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const const boost::filesystem::path& ConfigurationManager::getPluginsConfigPath() const
{ {
return mPluginsCfgPath; return mPluginsCfgPath;

@ -41,7 +41,6 @@ struct ConfigurationManager
const boost::filesystem::path& getLocalDataPath() const; const boost::filesystem::path& getLocalDataPath() const;
const boost::filesystem::path& getInstallPath() const; const boost::filesystem::path& getInstallPath() const;
const boost::filesystem::path& getOgreConfigPath() const;
const boost::filesystem::path& getPluginsConfigPath() const; const boost::filesystem::path& getPluginsConfigPath() const;
const boost::filesystem::path& getLogPath() const; const boost::filesystem::path& getLogPath() const;
@ -59,7 +58,6 @@ struct ConfigurationManager
FixedPathType mFixedPath; FixedPathType mFixedPath;
boost::filesystem::path mOgreCfgPath;
boost::filesystem::path mPluginsCfgPath; boost::filesystem::path mPluginsCfgPath;
boost::filesystem::path mLogPath; boost::filesystem::path mLogPath;

@ -1,6 +1,29 @@
# WARNING: Editing this file might have no effect, as these # WARNING: Editing this file might have no effect, as these
# settings are overwritten by your user settings file. # 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] [General]
# Camera field of view # Camera field of view
field of view = 55 field of view = 55

@ -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, &params);
} }
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();
} }

@ -33,124 +33,123 @@ namespace Ogre
class Viewport; class Viewport;
} }
namespace OEngine { namespace OEngine
namespace Render
{ {
class Fader; namespace Render
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)
{ {
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 #endif

Loading…
Cancel
Save