# HG changeset patch # User prock@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1286476622 0 # Node ID 855ad500f9916e51ad5349d472885ded19401237 # Parent 685d250f2c2dea77d9eae2823579196f5ef4d5c4 * 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. diff -r 685d250f2c2d -r 855ad500f991 engine/core/controller/engine.cpp --- 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(); diff -r 685d250f2c2d -r 855ad500f991 engine/core/controller/engine.i --- 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(); diff -r 685d250f2c2d -r 855ad500f991 engine/core/controller/enginesettings.cpp --- 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; + } } diff -r 685d250f2c2d -r 855ad500f991 engine/core/controller/enginesettings.h --- 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 diff -r 685d250f2c2d -r 855ad500f991 engine/core/video/opengl/renderbackendopengl.cpp --- 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()); diff -r 685d250f2c2d -r 855ad500f991 engine/core/video/opengl/renderbackendopengl.h --- 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); diff -r 685d250f2c2d -r 855ad500f991 engine/core/video/renderbackend.h --- 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 */ diff -r 685d250f2c2d -r 855ad500f991 engine/core/video/sdl/renderbackendsdl.cpp --- 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()); diff -r 685d250f2c2d -r 855ad500f991 engine/core/video/sdl/renderbackendsdl.h --- 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); diff -r 685d250f2c2d -r 855ad500f991 engine/python/fife/extensions/basicapplication.py --- 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))