diff options
author | Johannes Schickel | 2013-10-20 06:20:46 -0700 |
---|---|---|
committer | Johannes Schickel | 2013-10-20 06:20:46 -0700 |
commit | f20471d9624cd73d0568560ffa76d1ff74e3cd8d (patch) | |
tree | bb09e2589aadc7e92a185a38b95d0b3365c42ef2 /backends/platform | |
parent | 4c3972d68a3a120bec6f7e327990949c82689792 (diff) | |
parent | 05c347fc8ad8edc990c9d6e7c15a12d93bd8a3a3 (diff) | |
download | scummvm-rg350-f20471d9624cd73d0568560ffa76d1ff74e3cd8d.tar.gz scummvm-rg350-f20471d9624cd73d0568560ffa76d1ff74e3cd8d.tar.bz2 scummvm-rg350-f20471d9624cd73d0568560ffa76d1ff74e3cd8d.zip |
Merge pull request #408 from lordhoto/opengl-replacement
OpenGL revamp
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 21 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.h | 2 | ||||
-rw-r--r-- | backends/platform/tizen/graphics.cpp | 106 | ||||
-rw-r--r-- | backends/platform/tizen/graphics.h | 21 | ||||
-rw-r--r-- | backends/platform/tizen/system.cpp | 2 |
5 files changed, 66 insertions, 86 deletions
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 7ab367d4a4..1431e1fc5e 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -65,6 +65,8 @@ OSystem_SDL::OSystem_SDL() : #ifdef USE_OPENGL + _desktopWidth(0), + _desktopHeight(0), _graphicsModes(0), _graphicsMode(0), _sdlModesCount(0), @@ -161,6 +163,16 @@ void OSystem_SDL::initBackend() { int graphicsManagerType = 0; +#ifdef USE_OPENGL + // Query the desktop resolution. We simply hope nothing tried to change + // the resolution so far. + const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo(); + if (videoInfo && videoInfo->current_w > 0 && videoInfo->current_h > 0) { + _desktopWidth = videoInfo->current_w; + _desktopHeight = videoInfo->current_h; + } +#endif + if (_graphicsManager == 0) { #ifdef USE_OPENGL if (ConfMan.hasKey("gfx_mode")) { @@ -180,7 +192,7 @@ void OSystem_SDL::initBackend() { // If the gfx_mode is from OpenGL, create the OpenGL graphics manager if (use_opengl) { - _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource); + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); graphicsManagerType = 1; } } @@ -261,8 +273,9 @@ void OSystem_SDL::initSDL() { if (ConfMan.hasKey("disable_sdl_parachute")) sdlFlags |= SDL_INIT_NOPARACHUTE; -#ifdef WEBOS - // WebOS needs this flag or otherwise the application won't start +#if defined(WEBOS) || defined(USE_OPENGL) + // WebOS needs this flag or otherwise the application won't start. + // OpenGL SDL needs this to query the desktop resolution on startup. sdlFlags |= SDL_INIT_VIDEO; #endif @@ -591,7 +604,7 @@ bool OSystem_SDL::setGraphicsMode(int mode) { } else if (_graphicsMode < _sdlModesCount && mode >= _sdlModesCount) { debug(1, "switching to OpenGL graphics"); delete _graphicsManager; - _graphicsManager = new OpenGLSdlGraphicsManager(_eventSource); + _graphicsManager = new OpenGLSdlGraphicsManager(_desktopWidth, _desktopHeight, _eventSource); ((OpenGLSdlGraphicsManager *)_graphicsManager)->initEventObserver(); _graphicsManager->beginGFXTransaction(); diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 840e73ff09..590354b699 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -106,6 +106,8 @@ protected: Backends::Log::Log *_logger; #ifdef USE_OPENGL + int _desktopWidth, _desktopHeight; + OSystem::GraphicsMode *_graphicsModes; int _graphicsMode; int _sdlModesCount; diff --git a/backends/platform/tizen/graphics.cpp b/backends/platform/tizen/graphics.cpp index 2cafb9f781..390796dc0e 100644 --- a/backends/platform/tizen/graphics.cpp +++ b/backends/platform/tizen/graphics.cpp @@ -37,7 +37,6 @@ TizenGraphicsManager::TizenGraphicsManager(TizenAppForm *appForm) : _eglContext(EGL_NO_CONTEXT), _initState(true) { assert(appForm != NULL); - _videoMode.fullscreen = true; } TizenGraphicsManager::~TizenGraphicsManager() { @@ -51,17 +50,34 @@ TizenGraphicsManager::~TizenGraphicsManager() { } } +result TizenGraphicsManager::Construct() { + // Initialize our OpenGL ES context. + loadEgl(); + + // Notify the OpenGL code about our context. + + // We default to RGB565 and RGBA5551 which is closest to the actual output + // mode we setup. + notifyContextChange(Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + + // Tell our size. + int x, y, width, height; + _appForm->GetBounds(x, y, width, height); + AppLog("screen size: %dx%d", width, height); + setActualScreenSize(width, height); + return E_SUCCESS; +} + const Graphics::Font *TizenGraphicsManager::getFontOSD() { return FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); } bool TizenGraphicsManager::moveMouse(int16 &x, int16 &y) { - int16 currentX = _cursorState.x; - int16 currentY = _cursorState.y; + int16 currentX, currentY; + getMousePosition(currentX, currentY); // save the current hardware coordinates - _cursorState.x = x; - _cursorState.y = y; + setMousePosition(x, y); // return x/y as game coordinates adjustMousePosition(x, y); @@ -85,15 +101,17 @@ Common::List<Graphics::PixelFormat> TizenGraphicsManager::getSupportedFormats() } bool TizenGraphicsManager::hasFeature(OSystem::Feature f) { - bool result = (f == OSystem::kFeatureFullscreenMode || - f == OSystem::kFeatureVirtualKeyboard || + bool result = + (f == OSystem::kFeatureVirtualKeyboard || OpenGLGraphicsManager::hasFeature(f)); return result; } void TizenGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { - if (f == OSystem::kFeatureVirtualKeyboard && enable) { - _appForm->showKeypad(); + if (f == OSystem::kFeatureVirtualKeyboard) { + if (enable) { + _appForm->showKeypad(); + } } else { OpenGLGraphicsManager::setFeatureState(f, enable); } @@ -106,8 +124,9 @@ void TizenGraphicsManager::setReady() { } void TizenGraphicsManager::updateScreen() { - if (_transactionMode == kTransactionNone) { - internUpdateScreen(); + if (!_initState) { + OpenGLGraphicsManager::updateScreen(); + eglSwapBuffers(_eglDisplay, _eglSurface); } } @@ -133,10 +152,6 @@ bool TizenGraphicsManager::loadEgl() { eglBindAPI(EGL_OPENGL_ES_API); - if (_eglDisplay) { - unloadGFXMode(); - } - _eglDisplay = eglGetDisplay((EGLNativeDisplayType) EGL_DEFAULT_DISPLAY); if (EGL_NO_DISPLAY == _eglDisplay) { systemError("eglGetDisplay() failed"); @@ -178,65 +193,12 @@ bool TizenGraphicsManager::loadEgl() { systemError("eglMakeCurrent() failed"); return false; } - if (!_initState) { - _appForm->GetVisualElement()->SetShowState(true); - } logLeaving(); return true; } -bool TizenGraphicsManager::loadGFXMode() { - logEntered(); - - if (!loadEgl()) { - unloadGFXMode(); - return false; - } - - int x, y, width, height; - _appForm->GetBounds(x, y, width, height); - _videoMode.overlayWidth = _videoMode.hardwareWidth = width; - _videoMode.overlayHeight = _videoMode.hardwareHeight = height; - _videoMode.scaleFactor = 4; // for proportional sized cursor in the launcher - - AppLog("screen size: %dx%d", _videoMode.hardwareWidth, _videoMode.hardwareHeight); - return OpenGLGraphicsManager::loadGFXMode(); -} - -void TizenGraphicsManager::loadTextures() { - logEntered(); - OpenGLGraphicsManager::loadTextures(); -} - -void TizenGraphicsManager::internUpdateScreen() { - if (!_initState) { - OpenGLGraphicsManager::internUpdateScreen(); - eglSwapBuffers(_eglDisplay, _eglSurface); - } -} - -void TizenGraphicsManager::unloadGFXMode() { - logEntered(); - _appForm->GetVisualElement()->SetShowState(false); - - if (_eglDisplay != EGL_NO_DISPLAY) { - eglMakeCurrent(_eglDisplay, NULL, NULL, NULL); - - if (_eglContext != EGL_NO_CONTEXT) { - eglDestroyContext(_eglDisplay, _eglContext); - _eglContext = EGL_NO_CONTEXT; - } - - if (_eglSurface != EGL_NO_SURFACE) { - eglDestroySurface(_eglDisplay, _eglSurface); - _eglSurface = EGL_NO_SURFACE; - } - - eglTerminate(_eglDisplay); - _eglDisplay = EGL_NO_DISPLAY; - } - - _eglConfig = NULL; - OpenGLGraphicsManager::unloadGFXMode(); - logLeaving(); +bool TizenGraphicsManager::loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format) { + // We get this whenever a new resolution is requested. Since Tizen is + // using a fixed output size we do nothing like that here. + return true; } diff --git a/backends/platform/tizen/graphics.h b/backends/platform/tizen/graphics.h index 27e5a6aaeb..29ba86a3c4 100644 --- a/backends/platform/tizen/graphics.h +++ b/backends/platform/tizen/graphics.h @@ -39,28 +39,31 @@ using namespace Tizen::Graphics; using namespace Tizen::Graphics::Opengl; using namespace Tizen::App; -class TizenGraphicsManager : public OpenGLGraphicsManager { +class TizenGraphicsManager : public OpenGL::OpenGLGraphicsManager { public: TizenGraphicsManager(TizenAppForm *appForm); virtual ~TizenGraphicsManager(); + result Construct(); + Common::List<Graphics::PixelFormat> getSupportedFormats() const; bool hasFeature(OSystem::Feature f); - void updateScreen(); void setFeatureState(OSystem::Feature f, bool enable); + void updateScreen(); + void setReady(); bool isReady() { return !_initState; } - const Graphics::Font *getFontOSD(); + bool moveMouse(int16 &x, int16 &y); -private: - void internUpdateScreen(); - bool loadGFXMode(); - void loadTextures(); - void unloadGFXMode(); +protected: void setInternalMousePosition(int x, int y) {} - void showSplash(); + bool loadVideoMode(uint requestedWidth, uint requestedHeight, const Graphics::PixelFormat &format); + + const Graphics::Font *getFontOSD(); + +private: bool loadEgl(); TizenAppForm *_appForm; EGLDisplay _eglDisplay; diff --git a/backends/platform/tizen/system.cpp b/backends/platform/tizen/system.cpp index 3448dc1421..f7ebc46719 100644 --- a/backends/platform/tizen/system.cpp +++ b/backends/platform/tizen/system.cpp @@ -267,7 +267,7 @@ result TizenSystem::initModules() { } _graphicsManager = (GraphicsManager *)new TizenGraphicsManager(_appForm); - if (!_graphicsManager) { + if (!_graphicsManager || graphicsManager->Construct() != E_SUCCESS) { return E_OUT_OF_MEMORY; } |