Skip to content

Commit

Permalink
OPENGLSDL: More refactoring to avoid direct access of OpenGlGraphicsM…
Browse files Browse the repository at this point in the history
…anager's members.
  • Loading branch information
Johannes Schickel committed Mar 17, 2011
1 parent 83b199e commit f490e6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backends/graphics/opengl/opengl-graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ class OpenGLGraphicsManager : public GraphicsManager, public Common::EventObserv
*/
void setFullscreenMode(bool enable);

/**
* Query the fullscreen state.
*/
inline bool getFullscreenMode() const { return _videoMode.fullscreen; }

/**
* Set the scale factor.
*
Expand Down
18 changes: 11 additions & 7 deletions backends/graphics/openglsdl/openglsdl-graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,13 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

const bool isFullscreen = getFullscreenMode();

// In case we have an fullscreen mode and we are not in a rollback, detect
// a proper mode to use. In case we are in a rollback, we already detected
// a proper mode when setting up that mode, thus there is no need to run
// the detection again.
if (_videoMode.fullscreen && _transactionMode != kTransactionRollback) {
if (isFullscreen && _transactionMode != kTransactionRollback) {
if (!setupFullscreenMode())
// Failed setuping a fullscreen mode
return false;
Expand All @@ -339,7 +341,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {

uint32 flags = SDL_OPENGL;

if (_videoMode.fullscreen)
if (isFullscreen)
flags |= SDL_FULLSCREEN;
else
flags |= SDL_RESIZABLE;
Expand All @@ -365,7 +367,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() {
// Check if the screen is BGR format
_formatBGR = _hwscreen->format->Rshift != 0;

if (_videoMode.fullscreen) {
if (isFullscreen) {
_lastFullscreenModeWidth = _videoMode.hardwareWidth;
_lastFullscreenModeHeight = _videoMode.hardwareHeight;
ConfMan.setInt("last_fullscreen_mode_width", _lastFullscreenModeWidth);
Expand Down Expand Up @@ -436,12 +438,14 @@ bool OpenGLSdlGraphicsManager::isHotkey(const Common::Event &event) {

void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) {
beginGFXTransaction();
if (_videoMode.fullscreen && loop) {
const bool isFullscreen = getFullscreenMode();

if (isFullscreen && loop) {
_activeFullscreenMode += loop;
setFullscreenMode(true);
} else {
_activeFullscreenMode = -2;
setFullscreenMode(!_videoMode.fullscreen);
setFullscreenMode(!isFullscreen);
}
endGFXTransaction();

Expand All @@ -450,7 +454,7 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) {

#ifdef USE_OSD
char buffer[128];
if (_videoMode.fullscreen)
if (getFullscreenMode())
sprintf(buffer, "Fullscreen mode\n%d x %d",
_hwscreen->w, _hwscreen->h
);
Expand Down Expand Up @@ -614,7 +618,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
// there is no common resize event.
case OSystem_SDL::kSdlEventResize:
// Do not resize if ignoring resize events.
if (!_ignoreResizeFrames && !_videoMode.fullscreen) {
if (!_ignoreResizeFrames && !getFullscreenMode()) {
bool scaleChanged = false;
beginGFXTransaction();
_videoMode.hardwareWidth = event.mouse.x;
Expand Down

0 comments on commit f490e6f

Please sign in to comment.