Mercurial > fife-parpg
changeset 640:855ad500f991
* Added the ability to set/get the video driver used using the settings interface. Note that the default driver for the OS will be used unless explicitly specified.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 07 Oct 2010 18:37:02 +0000 |
parents | 685d250f2c2d |
children | 52708806f35c |
files | engine/core/controller/engine.cpp engine/core/controller/engine.i engine/core/controller/enginesettings.cpp engine/core/controller/enginesettings.h engine/core/video/opengl/renderbackendopengl.cpp engine/core/video/opengl/renderbackendopengl.h engine/core/video/renderbackend.h engine/core/video/sdl/renderbackendsdl.cpp engine/core/video/sdl/renderbackendsdl.h engine/python/fife/extensions/basicapplication.py |
diffstat | 10 files changed, 42 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/controller/engine.cpp Thu Oct 07 18:37:02 2010 +0000 @@ -195,7 +195,7 @@ } FL_LOG(_log, "Initializing render backend"); m_renderbackend->setColorKeyEnabled(m_settings.isColorKeyEnabled()); - m_renderbackend->init(); + m_renderbackend->init(m_settings.getVideoDriver()); FL_LOG(_log, "Querying device capabilities"); m_devcaps.fillDeviceCaps();
--- a/engine/core/controller/engine.i Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/controller/engine.i Thu Oct 07 18:37:02 2010 +0000 @@ -77,6 +77,8 @@ bool isColorKeyEnabled() const; void setColorKey(uint8_t r, uint8_t g, uint8_t b); const SDL_Color& getColorKey() const; + void setVideoDriver(const std::string& driver); + const std::string& getVideoDriver() const; private: EngineSettings();
--- a/engine/core/controller/enginesettings.cpp Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/controller/enginesettings.cpp Thu Oct 07 18:37:02 2010 +0000 @@ -50,10 +50,21 @@ m_defaultfontpath(""), m_defaultfontsize(8), m_defaultfontglyphs(""), - m_iscolorkeyenabled(false) { + m_iscolorkeyenabled(false){ m_colorkey.r = 255; m_colorkey.g = 0; m_colorkey.b = 255; + +#if defined( __unix__ ) + m_videodriver = "x11"; +#elif defined( WIN32 ) + m_videodriver = "windib"; +#elif defined( __APPLE_CC__ ) + m_videodriver = "x11"; +#else + m_videodriver = ""; +#endif + } EngineSettings::~EngineSettings() { @@ -180,5 +191,13 @@ const SDL_Color& EngineSettings::getColorKey() const { return m_colorkey; } + + void EngineSettings::setVideoDriver(const std::string& driver) { + m_videodriver = driver; + } + + const std::string& EngineSettings::getVideoDriver() const { + return m_videodriver; + } }
--- a/engine/core/controller/enginesettings.h Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/controller/enginesettings.h Thu Oct 07 18:37:02 2010 +0000 @@ -210,6 +210,10 @@ */ const SDL_Color& getColorKey() const; + void setVideoDriver(const std::string& driver); + + const std::string& getVideoDriver() const; + private: uint8_t m_bitsperpixel; bool m_fullscreen; @@ -227,6 +231,7 @@ std::string m_defaultfontglyphs; bool m_iscolorkeyenabled; SDL_Color m_colorkey; + std::string m_videodriver; }; }//FIFE
--- a/engine/core/video/opengl/renderbackendopengl.cpp Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.cpp Thu Oct 07 18:37:02 2010 +0000 @@ -55,7 +55,10 @@ } - void RenderBackendOpenGL::init() { + void RenderBackendOpenGL::init(const std::string& driver) { + + //note: driver has no affect on the opengl renderer so do nothing with it here. + Uint32 flags = SDL_INIT_VIDEO; if (SDL_InitSubSystem(flags) < 0) throw SDLException(SDL_GetError());
--- a/engine/core/video/opengl/renderbackendopengl.h Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.h Thu Oct 07 18:37:02 2010 +0000 @@ -44,7 +44,7 @@ const std::string& getName() const; void startFrame(); void endFrame(); - void init(); + void init(const std::string& driver); void clearBackBuffer(); Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen, const std::string& title, const std::string& icon);
--- a/engine/core/video/renderbackend.h Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/video/renderbackend.h Thu Oct 07 18:37:02 2010 +0000 @@ -74,7 +74,7 @@ /** Initializes the backend. */ - virtual void init() = 0; + virtual void init(const std::string& driver) = 0; /** Forces a clear of the backbuffer */
--- a/engine/core/video/sdl/renderbackendsdl.cpp Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/video/sdl/renderbackendsdl.cpp Thu Oct 07 18:37:02 2010 +0000 @@ -53,7 +53,12 @@ return backend_name; } - void RenderBackendSDL::init() { + void RenderBackendSDL::init(const std::string& driver) { + if (driver != "") { + std::string envVar = std::string("SDL_VIDEODRIVER=") + driver; + SDL_putenv(envVar.c_str()); + } + if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) throw SDLException(SDL_GetError());
--- a/engine/core/video/sdl/renderbackendsdl.h Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/core/video/sdl/renderbackendsdl.h Thu Oct 07 18:37:02 2010 +0000 @@ -46,7 +46,7 @@ void startFrame(); void endFrame(); - void init(); + void init(const std::string& driver); void clearBackBuffer(); Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen, const std::string& title, const std::string& icon);
--- a/engine/python/fife/extensions/basicapplication.py Thu Oct 07 16:44:44 2010 +0000 +++ b/engine/python/fife/extensions/basicapplication.py Thu Oct 07 18:37:02 2010 +0000 @@ -112,6 +112,7 @@ engineSetting.setScreenHeight(int(height)) engineSetting.setRenderBackend(self._setting.get("FIFE", "RenderBackend", "OpenGL")) engineSetting.setFullScreen(self._setting.get("FIFE", "FullScreen", False)) + engineSetting.setVideoDriver(self._setting.get("FIFE", "VideoDriver", "")) try: engineSetting.setColorKeyEnabled(self._setting.get("FIFE", "ColorKeyEnabled", False))