Moved getGraphicsManager() from OSystem_SDL to ModularBackend. Moved public SDL graphics manager functions to graphics manager (Allowing OpenGLSdlGraphicsMaanger to be used with other SDL managers easily). Removed BaseSdlGraphicsManager. Implemented in the opengl manager basic screen functions.
svn-id: r50796
This commit is contained in:
parent
85034dc730
commit
4dca7c7e02
13 changed files with 295 additions and 137 deletions
|
@ -324,7 +324,7 @@ bool SdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
|
|||
|
||||
// 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 (((OSystem_SDL *) g_system)->getGraphicsManager()->handleScalerHotkeys(ev.key))
|
||||
if (((OSystem_SDL *) g_system)->getGraphicsManager()->handleScalerHotkeys((Common::KeyCode)ev.key.keysym.sym))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "common/system.h"
|
||||
#include "common/noncopyable.h"
|
||||
#include "common/keyboard.h"
|
||||
|
||||
/**
|
||||
* Abstract class for graphics manager. Subclasses
|
||||
|
@ -84,6 +85,41 @@ public:
|
|||
virtual void disableCursorPalette(bool disable) = 0;
|
||||
|
||||
virtual void displayMessageOnOSD(const char *msg) {}
|
||||
|
||||
/**
|
||||
* Marks the screen for a full redraw
|
||||
*/
|
||||
virtual void forceFullRedraw() {};
|
||||
|
||||
/**
|
||||
* Handles the scalar hotkeys
|
||||
*/
|
||||
virtual bool handleScalerHotkeys(Common::KeyCode key) { return false; };
|
||||
|
||||
/**
|
||||
* Returns if the event passed is a hotkey for the graphics scalers
|
||||
*/
|
||||
virtual bool isScalerHotkey(const Common::Event &event) { return false; };
|
||||
|
||||
/**
|
||||
* Adjusts mouse event coords for the current scaler
|
||||
*/
|
||||
virtual void adjustMouseEvent(Common::Event &event) {};
|
||||
|
||||
/**
|
||||
* Updates the mouse cursor position
|
||||
*/
|
||||
virtual void setMousePos(int x, int y) {};
|
||||
|
||||
/**
|
||||
* Toggles fullscreen
|
||||
*/
|
||||
virtual void toggleFullScreen() {};
|
||||
|
||||
/**
|
||||
* Saves a screenshot to a file
|
||||
*/
|
||||
virtual bool saveScreenshot(const char *filename) { return false; };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,19 @@
|
|||
|
||||
OpenGLGraphicsManager::OpenGLGraphicsManager()
|
||||
:
|
||||
_gameTexture(0), _overlayTexture(0), _mouseTexture(0) {
|
||||
_gameTexture(0), _overlayTexture(0), _mouseTexture(0),
|
||||
_screenChangeCount(0),
|
||||
_transactionMode(0)
|
||||
|
||||
{
|
||||
|
||||
memset(&_oldVideoMode, 0, sizeof(_oldVideoMode));
|
||||
memset(&_videoMode, 0, sizeof(_videoMode));
|
||||
memset(&_transactionDetails, 0, sizeof(_transactionDetails));
|
||||
|
||||
_videoMode.mode = GFX_NORMAL;
|
||||
_videoMode.scaleFactor = 1;
|
||||
_videoMode.fullscreen = false;
|
||||
}
|
||||
|
||||
OpenGLGraphicsManager::~OpenGLGraphicsManager() {
|
||||
|
@ -93,7 +105,33 @@ Common::List<Graphics::PixelFormat> OpenGLGraphicsManager::getSupportedFormats()
|
|||
#endif
|
||||
|
||||
void OpenGLGraphicsManager::initSize(uint width, uint height, const Graphics::PixelFormat *format) {
|
||||
assert(_transactionMode == kTransactionActive);
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
//avoid redundant format changes
|
||||
Graphics::PixelFormat newFormat;
|
||||
if (!format)
|
||||
newFormat = Graphics::PixelFormat::createFormatCLUT8();
|
||||
else
|
||||
newFormat = *format;
|
||||
|
||||
assert(newFormat.bytesPerPixel > 0);
|
||||
|
||||
if (newFormat != _videoMode.format) {
|
||||
_videoMode.format = newFormat;
|
||||
_transactionDetails.formatChanged = true;
|
||||
_screenFormat = newFormat;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Avoid redundant res changes
|
||||
if ((int)width == _videoMode.screenWidth && (int)height == _videoMode.screenHeight)
|
||||
return;
|
||||
|
||||
_videoMode.screenWidth = width;
|
||||
_videoMode.screenHeight = height;
|
||||
|
||||
_transactionDetails.sizeChanged = true;
|
||||
}
|
||||
|
||||
int OpenGLGraphicsManager::getScreenChangeID() const {
|
||||
|
@ -105,11 +143,107 @@ int OpenGLGraphicsManager::getScreenChangeID() const {
|
|||
//
|
||||
|
||||
void OpenGLGraphicsManager::beginGFXTransaction() {
|
||||
assert(_transactionMode == kTransactionNone);
|
||||
|
||||
_transactionMode = kTransactionActive;
|
||||
_transactionDetails.sizeChanged = false;
|
||||
_transactionDetails.needHotswap = false;
|
||||
_transactionDetails.needUpdatescreen = false;
|
||||
#ifdef USE_RGB_COLOR
|
||||
_transactionDetails.formatChanged = false;
|
||||
#endif
|
||||
|
||||
_oldVideoMode = _videoMode;
|
||||
}
|
||||
|
||||
OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
|
||||
return OSystem::kTransactionSuccess;
|
||||
int errors = OSystem::kTransactionSuccess;
|
||||
|
||||
assert(_transactionMode != kTransactionNone);
|
||||
|
||||
if (_transactionMode == kTransactionRollback) {
|
||||
if (_videoMode.fullscreen != _oldVideoMode.fullscreen) {
|
||||
errors |= OSystem::kTransactionFullscreenFailed;
|
||||
|
||||
_videoMode.fullscreen = _oldVideoMode.fullscreen;
|
||||
/*} else if (_videoMode.aspectRatioCorrection != _oldVideoMode.aspectRatioCorrection) {
|
||||
errors |= OSystem::kTransactionAspectRatioFailed;
|
||||
|
||||
_videoMode.aspectRatioCorrection = _oldVideoMode.aspectRatioCorrection;*/
|
||||
} else if (_videoMode.mode != _oldVideoMode.mode) {
|
||||
errors |= OSystem::kTransactionModeSwitchFailed;
|
||||
|
||||
_videoMode.mode = _oldVideoMode.mode;
|
||||
_videoMode.scaleFactor = _oldVideoMode.scaleFactor;
|
||||
#ifdef USE_RGB_COLOR
|
||||
} else if (_videoMode.format != _oldVideoMode.format) {
|
||||
errors |= OSystem::kTransactionFormatNotSupported;
|
||||
|
||||
_videoMode.format = _oldVideoMode.format;
|
||||
_screenFormat = _videoMode.format;
|
||||
#endif
|
||||
} else if (_videoMode.screenWidth != _oldVideoMode.screenWidth || _videoMode.screenHeight != _oldVideoMode.screenHeight) {
|
||||
errors |= OSystem::kTransactionSizeChangeFailed;
|
||||
|
||||
_videoMode.screenWidth = _oldVideoMode.screenWidth;
|
||||
_videoMode.screenHeight = _oldVideoMode.screenHeight;
|
||||
_videoMode.overlayWidth = _oldVideoMode.overlayWidth;
|
||||
_videoMode.overlayHeight = _oldVideoMode.overlayHeight;
|
||||
}
|
||||
|
||||
if (_videoMode.fullscreen == _oldVideoMode.fullscreen &&
|
||||
//_videoMode.aspectRatioCorrection == _oldVideoMode.aspectRatioCorrection &&
|
||||
_videoMode.mode == _oldVideoMode.mode &&
|
||||
_videoMode.screenWidth == _oldVideoMode.screenWidth &&
|
||||
_videoMode.screenHeight == _oldVideoMode.screenHeight) {
|
||||
|
||||
// Our new video mode would now be exactly the same as the
|
||||
// old one. Since we still can not assume SDL_SetVideoMode
|
||||
// to be working fine, we need to invalidate the old video
|
||||
// mode, so loadGFXMode would error out properly.
|
||||
_oldVideoMode.setup = false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
if (_transactionDetails.sizeChanged || _transactionDetails.formatChanged) {
|
||||
#else
|
||||
if (_transactionDetails.sizeChanged) {
|
||||
#endif
|
||||
unloadGFXMode();
|
||||
if (!loadGFXMode()) {
|
||||
if (_oldVideoMode.setup) {
|
||||
_transactionMode = kTransactionRollback;
|
||||
errors |= endGFXTransaction();
|
||||
}
|
||||
} else {
|
||||
//setGraphicsModeIntern();
|
||||
//clearOverlay();
|
||||
|
||||
_videoMode.setup = true;
|
||||
_screenChangeCount++;
|
||||
}
|
||||
} else if (_transactionDetails.needHotswap) {
|
||||
//setGraphicsModeIntern();
|
||||
if (!hotswapGFXMode()) {
|
||||
if (_oldVideoMode.setup) {
|
||||
_transactionMode = kTransactionRollback;
|
||||
errors |= endGFXTransaction();
|
||||
}
|
||||
} else {
|
||||
_videoMode.setup = true;
|
||||
_screenChangeCount++;
|
||||
|
||||
if (_transactionDetails.needUpdatescreen)
|
||||
internUpdateScreen();
|
||||
}
|
||||
} else if (_transactionDetails.needUpdatescreen) {
|
||||
//setGraphicsModeIntern();
|
||||
internUpdateScreen();
|
||||
}
|
||||
|
||||
_transactionMode = kTransactionNone;
|
||||
return (OSystem::TransactionError)errors;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -117,11 +251,11 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() {
|
|||
//
|
||||
|
||||
int16 OpenGLGraphicsManager::getHeight() {
|
||||
return 0;
|
||||
return _videoMode.screenHeight;
|
||||
}
|
||||
|
||||
int16 OpenGLGraphicsManager::getWidth() {
|
||||
return 0;
|
||||
return _videoMode.screenWidth;
|
||||
}
|
||||
|
||||
void OpenGLGraphicsManager::setPalette(const byte *colors, uint start, uint num) {
|
||||
|
@ -194,11 +328,11 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch
|
|||
}
|
||||
|
||||
int16 OpenGLGraphicsManager::getOverlayHeight() {
|
||||
return 0;
|
||||
return _videoMode.overlayHeight;
|
||||
}
|
||||
|
||||
int16 OpenGLGraphicsManager::getOverlayWidth() {
|
||||
return 0;
|
||||
return _videoMode.overlayWidth;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -96,13 +96,54 @@ protected:
|
|||
GLTexture* _overlayTexture;
|
||||
GLTexture* _mouseTexture;
|
||||
|
||||
|
||||
Graphics::Surface _lockedScreen;
|
||||
|
||||
virtual void internUpdateScreen();
|
||||
virtual bool loadGFXMode();
|
||||
virtual void unloadGFXMode();
|
||||
virtual bool hotswapGFXMode();
|
||||
|
||||
Graphics::Surface _lockedScreen;
|
||||
int _screenChangeCount;
|
||||
|
||||
#ifdef USE_RGB_COLOR
|
||||
Graphics::PixelFormat _screenFormat;
|
||||
Graphics::PixelFormat _cursorFormat;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
kTransactionNone = 0,
|
||||
kTransactionActive = 1,
|
||||
kTransactionRollback = 2
|
||||
};
|
||||
|
||||
struct TransactionDetails {
|
||||
bool sizeChanged;
|
||||
bool needHotswap;
|
||||
bool needUpdatescreen;
|
||||
#ifdef USE_RGB_COLOR
|
||||
bool formatChanged;
|
||||
#endif
|
||||
};
|
||||
TransactionDetails _transactionDetails;
|
||||
int _transactionMode;
|
||||
|
||||
struct VideoState {
|
||||
bool setup;
|
||||
|
||||
bool fullscreen;
|
||||
//bool aspectRatioCorrection;
|
||||
//AspectRatio desiredAspectRatio;
|
||||
|
||||
int mode;
|
||||
int scaleFactor;
|
||||
|
||||
int screenWidth, screenHeight;
|
||||
int overlayWidth, overlayHeight;
|
||||
int hardwareWidth, hardwareHeight;
|
||||
#ifdef USE_RGB_COLOR
|
||||
Graphics::PixelFormat format;
|
||||
#endif
|
||||
};
|
||||
VideoState _videoMode, _oldVideoMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
|
||||
#include "backends/graphics/openglsdl/openglsdl-graphics.h"
|
||||
|
||||
OpenGLSDLGraphicsManager::OpenGLSDLGraphicsManager()
|
||||
OpenGLSdlGraphicsManager::OpenGLSdlGraphicsManager()
|
||||
:
|
||||
_hwscreen(0) {
|
||||
|
||||
}
|
||||
|
||||
OpenGLSDLGraphicsManager::~OpenGLSDLGraphicsManager() {
|
||||
OpenGLSdlGraphicsManager::~OpenGLSdlGraphicsManager() {
|
||||
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::init() {
|
||||
void OpenGLSdlGraphicsManager::init() {
|
||||
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) {
|
||||
error("Could not initialize SDL: %s", SDL_GetError());
|
||||
}
|
||||
|
@ -45,50 +45,74 @@ void OpenGLSDLGraphicsManager::init() {
|
|||
OpenGLGraphicsManager::init();
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::forceFullRedraw() {
|
||||
void OpenGLSdlGraphicsManager::forceFullRedraw() {
|
||||
|
||||
}
|
||||
|
||||
bool OpenGLSDLGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
|
||||
bool OpenGLSdlGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool OpenGLSDLGraphicsManager::isScalerHotkey(const Common::Event &event) {
|
||||
bool OpenGLSdlGraphicsManager::isScalerHotkey(const Common::Event &event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::adjustMouseEvent(Common::Event &event) {
|
||||
void OpenGLSdlGraphicsManager::adjustMouseEvent(Common::Event &event) {
|
||||
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::setMousePos(int x, int y) {
|
||||
void OpenGLSdlGraphicsManager::setMousePos(int x, int y) {
|
||||
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::toggleFullScreen() {
|
||||
void OpenGLSdlGraphicsManager::toggleFullScreen() {
|
||||
|
||||
}
|
||||
|
||||
bool OpenGLSDLGraphicsManager::saveScreenshot(const char *filename) {
|
||||
bool OpenGLSdlGraphicsManager::saveScreenshot(const char *filename) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected
|
||||
// Intern
|
||||
//
|
||||
|
||||
bool OpenGLSDLGraphicsManager::loadGFXMode() {
|
||||
bool OpenGLSdlGraphicsManager::loadGFXMode() {
|
||||
_videoMode.overlayWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
|
||||
_videoMode.overlayHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
|
||||
_videoMode.hardwareWidth = _videoMode.screenWidth * _videoMode.scaleFactor;
|
||||
_videoMode.hardwareHeight = _videoMode.screenHeight * _videoMode.scaleFactor;
|
||||
|
||||
|
||||
_hwscreen = SDL_SetVideoMode(_videoMode.hardwareWidth, _videoMode.hardwareHeight, 32,
|
||||
_videoMode.fullscreen ? (SDL_FULLSCREEN | SDL_OPENGL) : SDL_OPENGL
|
||||
);
|
||||
if (_hwscreen == NULL) {
|
||||
// DON'T use error(), as this tries to bring up the debug
|
||||
// console, which WON'T WORK now that _hwscreen is hosed.
|
||||
|
||||
if (!_oldVideoMode.setup) {
|
||||
warning("SDL_SetVideoMode says we can't switch to that mode (%s)", SDL_GetError());
|
||||
g_system->quit();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OpenGLSdlGraphicsManager::unloadGFXMode() {
|
||||
if (_hwscreen) {
|
||||
SDL_FreeSurface(_hwscreen);
|
||||
_hwscreen = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool OpenGLSdlGraphicsManager::hotswapGFXMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::unloadGFXMode() {
|
||||
|
||||
}
|
||||
|
||||
bool OpenGLSDLGraphicsManager::hotswapGFXMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OpenGLSDLGraphicsManager::internUpdateScreen() {
|
||||
void OpenGLSdlGraphicsManager::internUpdateScreen() {
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@
|
|||
/**
|
||||
* SDL OpenGL graphics manager
|
||||
*/
|
||||
class OpenGLSDLGraphicsManager : public OpenGLGraphicsManager {
|
||||
class OpenGLSdlGraphicsManager : public OpenGLGraphicsManager {
|
||||
public:
|
||||
OpenGLSDLGraphicsManager();
|
||||
virtual ~OpenGLSDLGraphicsManager();
|
||||
OpenGLSdlGraphicsManager();
|
||||
virtual ~OpenGLSdlGraphicsManager();
|
||||
|
||||
virtual void init();
|
||||
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* $URL$
|
||||
* $Id$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BACKENDS_GRAPHICS_BASESDL_H
|
||||
#define BACKENDS_GRAPHICS_BASESDL_H
|
||||
|
||||
#include "backends/graphics/graphics.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Base SDL graphics manager, contains common functions
|
||||
* used by other SDL managers
|
||||
*/
|
||||
class BaseSdlGraphicsManager : public GraphicsManager {
|
||||
public:
|
||||
/**
|
||||
* Marks the screen for a full redraw
|
||||
*/
|
||||
virtual void forceFullRedraw() = 0;
|
||||
|
||||
/**
|
||||
* Handles the scalar hotkeys
|
||||
*/
|
||||
virtual bool handleScalerHotkeys(const SDL_KeyboardEvent &key) = 0;
|
||||
|
||||
/**
|
||||
* Returns if the event passed is a hotkey for the graphics scalers
|
||||
*/
|
||||
virtual bool isScalerHotkey(const Common::Event &event) = 0;
|
||||
|
||||
/**
|
||||
* Adjusts mouse event coords for the current scaler
|
||||
*/
|
||||
virtual void adjustMouseEvent(Common::Event &event) = 0;
|
||||
|
||||
/**
|
||||
* Updates the mouse cursor position
|
||||
*/
|
||||
virtual void setMousePos(int x, int y) = 0;
|
||||
|
||||
/**
|
||||
* Toggles fullscreen
|
||||
*/
|
||||
virtual void toggleFullScreen() = 0;
|
||||
|
||||
/**
|
||||
* Saves a screenshot to a file
|
||||
*/
|
||||
virtual bool saveScreenshot(const char *filename) = 0;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1967,9 +1967,10 @@ void SdlGraphicsManager::displayMessageOnOSD(const char *msg) {
|
|||
}
|
||||
#endif
|
||||
|
||||
bool SdlGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
|
||||
bool SdlGraphicsManager::handleScalerHotkeys(Common::KeyCode key) {
|
||||
|
||||
// Ctrl-Alt-a toggles aspect ratio correction
|
||||
if (key.keysym.sym == 'a') {
|
||||
if (key == 'a') {
|
||||
beginGFXTransaction();
|
||||
setFeatureState(OSystem::kFeatureAspectRatioCorrection, !_videoMode.aspectRatioCorrection);
|
||||
endGFXTransaction();
|
||||
|
@ -1995,18 +1996,18 @@ bool SdlGraphicsManager::handleScalerHotkeys(const SDL_KeyboardEvent &key) {
|
|||
int factor = _videoMode.scaleFactor - 1;
|
||||
|
||||
// Increase/decrease the scale factor
|
||||
if (key.keysym.sym == SDLK_EQUALS || key.keysym.sym == SDLK_PLUS || key.keysym.sym == SDLK_MINUS ||
|
||||
key.keysym.sym == SDLK_KP_PLUS || key.keysym.sym == SDLK_KP_MINUS) {
|
||||
factor += (key.keysym.sym == SDLK_MINUS || key.keysym.sym == SDLK_KP_MINUS) ? -1 : +1;
|
||||
if (key == SDLK_EQUALS || key == SDLK_PLUS || key == SDLK_MINUS ||
|
||||
key == SDLK_KP_PLUS || key == SDLK_KP_MINUS) {
|
||||
factor += (key == SDLK_MINUS || key == SDLK_KP_MINUS) ? -1 : +1;
|
||||
if (0 <= factor && factor <= 3) {
|
||||
newMode = s_gfxModeSwitchTable[_scalerType][factor];
|
||||
}
|
||||
}
|
||||
|
||||
const bool isNormalNumber = (SDLK_1 <= key.keysym.sym && key.keysym.sym <= SDLK_9);
|
||||
const bool isKeypadNumber = (SDLK_KP1 <= key.keysym.sym && key.keysym.sym <= SDLK_KP9);
|
||||
const bool isNormalNumber = (SDLK_1 <= key && key <= SDLK_9);
|
||||
const bool isKeypadNumber = (SDLK_KP1 <= key && key <= SDLK_KP9);
|
||||
if (isNormalNumber || isKeypadNumber) {
|
||||
_scalerType = key.keysym.sym - (isNormalNumber ? SDLK_1 : SDLK_KP1);
|
||||
_scalerType = key - (isNormalNumber ? SDLK_1 : SDLK_KP1);
|
||||
if (_scalerType >= ARRAYSIZE(s_gfxModeSwitchTable))
|
||||
return false;
|
||||
|
||||
|
|
|
@ -26,10 +26,16 @@
|
|||
#ifndef BACKENDS_GRAPHICS_SDL_H
|
||||
#define BACKENDS_GRAPHICS_SDL_H
|
||||
|
||||
#include "backends/graphics/sdl/basesdl-graphics.h"
|
||||
#include "backends/graphics/graphics.h"
|
||||
#include "common/system.h"
|
||||
#include "graphics/scaler.h"
|
||||
|
||||
#if defined(__SYMBIAN32__)
|
||||
#include <esdl\SDL.h>
|
||||
#else
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32_WCE) && !defined(__SYMBIAN32__)
|
||||
// Uncomment this to enable the 'on screen display' code.
|
||||
#define USE_OSD 1
|
||||
|
@ -66,7 +72,7 @@ public:
|
|||
/**
|
||||
* SDL graphics manager
|
||||
*/
|
||||
class SdlGraphicsManager : public BaseSdlGraphicsManager {
|
||||
class SdlGraphicsManager : public GraphicsManager {
|
||||
public:
|
||||
SdlGraphicsManager();
|
||||
virtual ~SdlGraphicsManager();
|
||||
|
@ -122,7 +128,7 @@ public:
|
|||
#endif
|
||||
|
||||
virtual void forceFullRedraw();
|
||||
virtual bool handleScalerHotkeys(const SDL_KeyboardEvent &key);
|
||||
virtual bool handleScalerHotkeys(Common::KeyCode key);
|
||||
virtual bool isScalerHotkey(const Common::Event &event);
|
||||
virtual void adjustMouseEvent(Common::Event &event);
|
||||
virtual void setMousePos(int x, int y);
|
||||
|
|
|
@ -70,6 +70,11 @@ bool ModularBackend::getFeatureState(Feature f) {
|
|||
return _graphicsManager->getFeatureState(f);
|
||||
}
|
||||
|
||||
GraphicsManager *ModularBackend::getGraphicsManager() {
|
||||
assert(_graphicsManager);
|
||||
return (GraphicsManager *)_graphicsManager;
|
||||
}
|
||||
|
||||
const OSystem::GraphicsMode *ModularBackend::getSupportedGraphicsModes() const {
|
||||
return _graphicsManager->getSupportedGraphicsModes();
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
/** @name Graphics */
|
||||
//@{
|
||||
|
||||
virtual GraphicsManager *getGraphicsManager();
|
||||
virtual const GraphicsMode *getSupportedGraphicsModes() const;
|
||||
virtual int getDefaultGraphicsMode() const;
|
||||
virtual bool setGraphicsMode(int mode);
|
||||
|
|
|
@ -86,9 +86,9 @@ void OSystem_SDL::initBackend() {
|
|||
if (_graphicsManager == 0) {
|
||||
// Changed to OpenGL for testing
|
||||
//_graphicsManager = new SdlGraphicsManager();
|
||||
_graphicsManager = new OpenGLSDLGraphicsManager();
|
||||
_graphicsManager = new OpenGLSdlGraphicsManager();
|
||||
|
||||
((OpenGLSDLGraphicsManager *)_graphicsManager)->init();
|
||||
((OpenGLSdlGraphicsManager *)_graphicsManager)->init();
|
||||
}
|
||||
|
||||
if (_audiocdManager == 0)
|
||||
|
@ -241,11 +241,6 @@ void OSystem_SDL::setupIcon() {
|
|||
free(icon);
|
||||
}
|
||||
|
||||
BaseSdlGraphicsManager *OSystem_SDL::getGraphicsManager() {
|
||||
assert(_graphicsManager);
|
||||
return (BaseSdlGraphicsManager *)_graphicsManager;
|
||||
}
|
||||
|
||||
bool OSystem_SDL::pollEvent(Common::Event &event) {
|
||||
assert(_eventManager);
|
||||
return ((SdlEventManager *)_eventManager)->pollSdlEvent(event);
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#endif
|
||||
|
||||
#include "backends/modular-backend.h"
|
||||
#include "backends/graphics/sdl/basesdl-graphics.h"
|
||||
#include "backends/mixer/sdl/sdl-mixer.h"
|
||||
|
||||
/**
|
||||
|
@ -51,11 +50,6 @@ public:
|
|||
*/
|
||||
virtual void init();
|
||||
|
||||
/**
|
||||
* Get the Graphics Manager instance. Used by other managers.
|
||||
*/
|
||||
virtual BaseSdlGraphicsManager *getGraphicsManager();
|
||||
|
||||
/**
|
||||
* Get the Mixer Manager instance. Not to confuse with getMixer(),
|
||||
* that returns Audio::Mixer. The Mixer Manager is a SDL wrapper class
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue