Mercurial > fife-parpg
changeset 653:01acc9fc35ea
* Moved getCurrentScreenMode() to the renderbackend as renderbackend is what initializes the screen.
* Updated the Color masks to follow the integer standards
* Added some new SDL modes (HW Surface and double buffer) to check for in DeviceCaps.
* RenderBackend now saves the actual flags used to initialize the screen.
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 15 Oct 2010 18:54:34 +0000 |
parents | da9c4cfe8f8e |
children | 5d6b1820b953 |
files | engine/core/controller/engine.cpp engine/core/controller/engine.h engine/core/controller/engine.i engine/core/util/base/fife_stdint.h engine/core/video/devicecaps.cpp engine/core/video/devicecaps.h engine/core/video/opengl/renderbackendopengl.cpp engine/core/video/renderbackend.cpp engine/core/video/renderbackend.h engine/core/video/sdl/renderbackendsdl.cpp engine/core/video/video.i |
diffstat | 11 files changed, 77 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/controller/engine.cpp Fri Oct 15 18:54:34 2010 +0000 @@ -131,10 +131,6 @@ return m_devcaps; } - const ScreenMode& Engine::getCurrentScreenMode() const{ - return m_screenMode; - } - void Engine::preInit() { m_logmanager = LogManager::instance();
--- a/engine/core/controller/engine.h Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/controller/engine.h Fri Oct 15 18:54:34 2010 +0000 @@ -88,10 +88,6 @@ */ const DeviceCaps& getDeviceCaps() const; - /** Get current video mode - */ - const ScreenMode& getCurrentScreenMode() const; - /** Initializes the engine */ void init();
--- a/engine/core/controller/engine.i Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/controller/engine.i Fri Oct 15 18:54:34 2010 +0000 @@ -95,7 +95,6 @@ EngineSettings& getSettings(); const DeviceCaps& getDeviceCaps() const; - const ScreenMode& getCurrentScreenMode() const; void init(); void destroy();
--- a/engine/core/util/base/fife_stdint.h Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/util/base/fife_stdint.h Fri Oct 15 18:54:34 2010 +0000 @@ -50,17 +50,17 @@ // SDL masks for SDL_CreateRGBSurface namespace FIFE { #if SDL_BYTEORDER == SDL_LIL_ENDIAN - const int RMASK = 0xff000000; - const int GMASK = 0x00ff0000; - const int BMASK = 0x0000ff00; - const int AMASK = 0x000000ff; + const uint32_t RMASK = 0xff000000; + const uint32_t GMASK = 0x00ff0000; + const uint32_t BMASK = 0x0000ff00; + const uint32_t AMASK = 0x000000ff; #else - const int RMASK = 0x000000ff; - const int GMASK = 0x0000ff00; - const int BMASK = 0x00ff0000; - const int AMASK = 0xff000000; + const uint32_t RMASK = 0x000000ff; + const uint32_t GMASK = 0x0000ff00; + const uint32_t BMASK = 0x00ff0000; + const uint32_t AMASK = 0xff000000; #endif - const int NULLMASK = 0x00000000; + const int32_t NULLMASK = 0x00000000; } //FIFE #endif // FIFEINT_H
--- a/engine/core/video/devicecaps.cpp Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/devicecaps.cpp Fri Oct 15 18:54:34 2010 +0000 @@ -56,8 +56,18 @@ if (m_bpp < rhs.getBPP() ) { return true; } + else if (m_bpp == rhs.getBPP()) { - if (m_width < rhs.getWidth() || m_height < rhs.getHeight()) { + if (m_width == rhs.getWidth() && m_height == rhs.getHeight()){ + if (!(m_SDLFlags & SDL_HWSURFACE) && (rhs.getSDLFlags() & SDL_HWSURFACE)) { + //I would like return true so that we prefer hardware surfaces but + //it really slows the engine down in fullscreen. See the SDL FAQ for an + //explanation. + return false; + } + } + + else if (m_width < rhs.getWidth() || m_height < rhs.getHeight()) { return true; } } @@ -134,7 +144,7 @@ //FLAGS #ifdef HAVE_OPENGL - const uint32_t numFlags = 4; + const uint32_t numFlags = 6; uint32_t flags[numFlags]; //OpenGL, windowed, hw accel @@ -143,16 +153,25 @@ flags[1] = ScreenMode::HW_FULLSCREEN_OPENGL; //SDL, windowed flags[2] = ScreenMode::WINDOWED_SDL; + //SDL, windowed, hw surface, double buffer + flags[3] = ScreenMode::WINDOWED_SDL_DB_HW; //SDL, fullscreen - flags[3] = ScreenMode::FULLSCREEN_SDL; + flags[4] = ScreenMode::FULLSCREEN_SDL; + //SDL, fullscreen, hw surface, double buffer + flags[5] = ScreenMode::FULLSCREEN_SDL_DB_HW; + #else - const uint32_tnumFlags = 2; + const uint32_tnumFlags = 4; uint32_t flags[numFlags]; //SDL, windowed flags[0] = ScreenMode::WINDOWED_SDL; + //SDL, windowed, hw surface, double buffer + flags[1] = ScreenMode::WINDOWED_SDL_DB_HW; //SDL, fullscreen - flags[1] = ScreenMode::FULLSCREEN_SDL; + flags[2] = ScreenMode::FULLSCREEN_SDL; + //SDL, fullscreen, hw surface, double buffer + flags[3] = ScreenMode::FULLSCREEN_SDL_DB_HW; #endif //BITS PER PIXEL
--- a/engine/core/video/devicecaps.h Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/devicecaps.h Fri Oct 15 18:54:34 2010 +0000 @@ -81,6 +81,14 @@ */ bool isOpenGL() const { return (m_SDLFlags & SDL_OPENGL) ? true : false; }; + /** Is this screen mode an SDL only screen mode + */ + bool isSDL() const { return (!(m_SDLFlags & SDL_OPENGL)) ? true : false; }; + + /** Returns true if this is a SDL screen mode with the SDL hardware surface enabled + */ + bool isSDLHardwareSurface() const { return (m_SDLFlags & SDL_HWSURFACE) ? true : false; }; + //OpenGL, windowed, hw accel static const uint32_t HW_WINDOWED_OPENGL = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL; @@ -88,8 +96,12 @@ static const uint32_t HW_FULLSCREEN_OPENGL = SDL_OPENGL | SDL_HWPALETTE | SDL_HWACCEL | SDL_FULLSCREEN; //SDL, windowed static const uint32_t WINDOWED_SDL = 0; + //SDL, windowed, HW surface and double buffer + static const uint32_t WINDOWED_SDL_DB_HW = SDL_HWSURFACE | SDL_DOUBLEBUF; //SDL, fullscreen static const uint32_t FULLSCREEN_SDL = SDL_FULLSCREEN; + //SDL, fullscreen, HW surface and double buffer + static const uint32_t FULLSCREEN_SDL_DB_HW = SDL_FULLSCREEN | SDL_HWSURFACE | SDL_DOUBLEBUF; private: uint16_t m_width;
--- a/engine/core/video/opengl/renderbackendopengl.cpp Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/opengl/renderbackendopengl.cpp Fri Oct 15 18:54:34 2010 +0000 @@ -76,6 +76,7 @@ } Image* RenderBackendOpenGL::createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon){ + m_screenMode = mode; unsigned int width = mode.getWidth(); unsigned int height = mode.getHeight(); unsigned char bitsPerPixel = mode.getBPP(); @@ -123,6 +124,13 @@ << "Videomode " << width << "x" << height << " at " << int(bitsPerPixel) << " bpp"); + //update the screen mode with the actual flags used + + m_screenMode = ScreenMode(m_screenMode.getWidth(), + m_screenMode.getHeight(), + m_screenMode.getBPP(), + screen->flags); + SDL_WM_SetCaption(title.c_str(), 0); if (!screen) {
--- a/engine/core/video/renderbackend.cpp Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/renderbackend.cpp Fri Oct 15 18:54:34 2010 +0000 @@ -75,6 +75,10 @@ return m_screen->getSurface(); } + const ScreenMode& RenderBackend::getCurrentScreenMode() const{ + return m_screenMode; + } + unsigned int RenderBackend::getWidth() const { assert(m_screen); return m_screen->getWidth();
--- a/engine/core/video/renderbackend.h Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/renderbackend.h Fri Oct 15 18:54:34 2010 +0000 @@ -39,13 +39,13 @@ #include "util/base/singleton.h" #include "util/structures/point.h" #include "util/structures/rect.h" +#include "video/devicecaps.h" #include "image.h" namespace FIFE { class Image; - class ScreenMode; /** Abstract interface for all the renderbackends. */ class RenderBackend: public AbstractImage, public DynamicSingleton<RenderBackend> { @@ -117,6 +117,11 @@ void captureScreen(const std::string& filename); SDL_Surface* getSurface(); + + /** Get current video mode + */ + const ScreenMode& getCurrentScreenMode() const; + unsigned int getWidth() const; unsigned int getHeight() const; unsigned int getScreenWidth() const { return getWidth(); } @@ -158,6 +163,7 @@ unsigned int m_chunkingsize; bool m_iscolorkeyenabled; SDL_Color m_colorkey; + ScreenMode m_screenMode; }; }
--- a/engine/core/video/sdl/renderbackendsdl.cpp Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/sdl/renderbackendsdl.cpp Fri Oct 15 18:54:34 2010 +0000 @@ -80,6 +80,7 @@ } Image* RenderBackendSDL::createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon){ + m_screenMode = mode; unsigned int width = mode.getWidth(); unsigned int height = mode.getHeight(); unsigned char bitsPerPixel = mode.getBPP(); @@ -129,6 +130,13 @@ << "Videomode " << width << "x" << height << " at " << int(screen->format->BitsPerPixel) << " bpp"); + //update the screen mode with the actual flags used + + m_screenMode = ScreenMode(m_screenMode.getWidth(), + m_screenMode.getHeight(), + m_screenMode.getBPP(), + screen->flags); + SDL_WM_SetCaption(title.c_str(), NULL); if (!screen) {
--- a/engine/core/video/video.i Fri Oct 15 15:13:10 2010 +0000 +++ b/engine/core/video/video.i Fri Oct 15 18:54:34 2010 +0000 @@ -158,6 +158,7 @@ Image* getScreenImage() const { return m_screen; }; void captureScreen(const std::string& filename); SDL_Surface* getSurface(); + const ScreenMode& getCurrentScreenMode() const; unsigned int getWidth() const; unsigned int getHeight() const; unsigned int getScreenWidth() const { return getWidth(); } @@ -239,11 +240,15 @@ uint32_t getSDLFlags() const; bool isFullScreen(); bool isOpenGL(); + bool isSDL() const; + bool isSDLHardwareSurface() const; static const uint32_t HW_WINDOWED_OPENGL; static const uint32_t HW_FULLSCREEN_OPENGL; static const uint32_t WINDOWED_SDL; + static const uint32_t WINDOWED_SDL_DB_HW; static const uint32_t FULLSCREEN_SDL; + static const uint32_t FULLSCREEN_SDL_DB_HW; }; class DeviceCaps {