aboutsummaryrefslogtreecommitdiff
path: root/backends/graphics/openglsdl
diff options
context:
space:
mode:
authorAlejandro Marzini2010-07-19 05:36:10 +0000
committerAlejandro Marzini2010-07-19 05:36:10 +0000
commit6f70a303bcda770b831e4d22b119f814d2a3a29d (patch)
tree9d0652a2708a2cc192221967c47d5172e390b8d8 /backends/graphics/openglsdl
parent38b4098f676cd222ba6c5f638d3a6a61974d5f88 (diff)
downloadscummvm-rg350-6f70a303bcda770b831e4d22b119f814d2a3a29d.tar.gz
scummvm-rg350-6f70a303bcda770b831e4d22b119f814d2a3a29d.tar.bz2
scummvm-rg350-6f70a303bcda770b831e4d22b119f814d2a3a29d.zip
OPENGL: Add basic scaler handle.
svn-id: r51016
Diffstat (limited to 'backends/graphics/openglsdl')
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.cpp126
-rw-r--r--backends/graphics/openglsdl/openglsdl-graphics.h8
2 files changed, 133 insertions, 1 deletions
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 99468b1447..938eaaf4c3 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -26,6 +26,7 @@
#ifdef USE_OPENGL
#include "backends/graphics/openglsdl/openglsdl-graphics.h"
+#include "backends/platform/sdl/sdl.h"
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()
:
@@ -135,7 +136,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
- _videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : SDL_OPENGL
+ _videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : (SDL_OPENGL | SDL_RESIZABLE)
);
if (_hwscreen == NULL) {
// DON'T use error(), as this tries to bring up the debug
@@ -169,4 +170,127 @@ void OpenGLSdlGraphicsManager::internUpdateScreen() {
SDL_GL_SwapBuffers();
}
+bool OpenGLSdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
+
+ // Ctrl-Alt-a toggles aspect ratio correction
+ /*if (key == 'a') {
+ beginGFXTransaction();
+ setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection);
+ endGFXTransaction();
+#ifdef USE_OSD
+ char buffer[128];
+ if (_videoMode.aspectRatioCorrection)
+ sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
+ _videoMode.screenWidth, _videoMode.screenHeight,
+ _hwscreen->w, _hwscreen->h
+ );
+ else
+ sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
+ _videoMode.screenWidth, _videoMode.screenHeight,
+ _hwscreen->w, _hwscreen->h
+ );
+ displayMessageOnOSD(buffer);
+#endif
+ internUpdateScreen();
+ return true;
+ }*/
+
+ SDLKey sdlKey = (SDLKey)key;
+
+ // Increase/decrease the scale factor
+ if (sdlKey == SDLK_EQUALS || sdlKey == SDLK_PLUS || sdlKey == SDLK_MINUS ||
+ sdlKey == SDLK_KP_PLUS || sdlKey == SDLK_KP_MINUS) {
+ int factor = _videoMode.scaleFactor;
+ factor += (sdlKey == SDLK_MINUS || sdlKey == SDLK_KP_MINUS) ? -1 : +1;
+ if (0 < factor && factor < 4) {
+ beginGFXTransaction();
+ setScale(factor);
+ endGFXTransaction();
+ }
+ }
+ return false;
+}
+
+void OpenGLSdlGraphicsManager::setFullscreenMode(bool enable) {
+
+}
+
+bool OpenGLSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
+ if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
+ const bool isScaleKey = (event.kbd.keycode == Common::KEYCODE_EQUALS || event.kbd.keycode == Common::KEYCODE_PLUS || event.kbd.keycode == Common::KEYCODE_MINUS ||
+ event.kbd.keycode == Common::KEYCODE_KP_PLUS || event.kbd.keycode == Common::KEYCODE_KP_MINUS);
+
+ return (isScaleKey || event.kbd.keycode == 'a');
+ }
+ return false;
+}
+
+void OpenGLSdlGraphicsManager::toggleFullScreen() {
+ beginGFXTransaction();
+ setFullscreenMode(!_videoMode.fullscreen);
+ endGFXTransaction();
+#ifdef USE_OSD
+ if (_videoMode.fullscreen)
+ displayMessageOnOSD("Fullscreen mode");
+ else
+ displayMessageOnOSD("Windowed mode");
+#endif
+}
+
+bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
+ switch ((int)event.type) {
+ case Common::EVENT_KEYDOWN:
+ // Alt-Return and Alt-Enter toggle full screen mode
+ if (event.kbd.hasFlags(Common::KBD_ALT) &&
+ (event.kbd.keycode == Common::KEYCODE_RETURN ||
+ event.kbd.keycode == (Common::KeyCode)SDLK_KP_ENTER)) {
+ toggleFullScreen();
+ return true;
+ }
+
+ // Alt-S: Create a screenshot
+ if (event.kbd.hasFlags(Common::KBD_ALT) && event.kbd.keycode == 's') {
+ char filename[20];
+
+ for (int n = 0;; n++) {
+ SDL_RWops *file;
+
+ sprintf(filename, "scummvm%05d.bmp", n);
+ file = SDL_RWFromFile(filename, "r");
+ if (!file)
+ break;
+ SDL_RWclose(file);
+ }
+ if (saveScreenshot(filename))
+ printf("Saved '%s'\n", filename);
+ else
+ printf("Could not save screenshot!\n");
+ return true;
+ }
+
+ // Ctrl-Alt-<key> will change the GFX mode
+ if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
+ if (handleScalerHotkeys(event.kbd.keycode))
+ return true;
+ }
+ case Common::EVENT_KEYUP:
+ return isScalerHotkey(event);
+ /*case OSystem_SDL::kSdlEventExpose:
+ break;*/
+ // HACK: Handle special SDL event
+ case OSystem_SDL::kSdlEventResize:
+ _videoMode.overlayWidth = event.mouse.x;
+ _videoMode.overlayHeight = event.mouse.y;
+ _videoMode.hardwareWidth = event.mouse.x;
+ _videoMode.hardwareHeight = event.mouse.y;
+ initGL();
+ return true;
+
+ default:
+ break;
+ }
+
+ return OpenGLGraphicsManager::notifyEvent(event);
+}
+
#endif
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.h b/backends/graphics/openglsdl/openglsdl-graphics.h
index f1f0d5ff37..4937e33eef 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.h
+++ b/backends/graphics/openglsdl/openglsdl-graphics.h
@@ -48,6 +48,8 @@ public:
virtual void warpMouse(int x, int y);
+ virtual bool notifyEvent(const Common::Event &event);
+
protected:
virtual void internUpdateScreen();
@@ -55,6 +57,12 @@ protected:
virtual void unloadGFXMode();
virtual bool hotswapGFXMode();
+ virtual void setFullscreenMode(bool enable);
+
+ virtual bool handleScalerHotkeys(Common::KeyCode key);
+ virtual bool isScalerHotkey(const Common::Event &event);
+ virtual void toggleFullScreen();
+
// Hardware screen
SDL_Surface *_hwscreen;
};