2019-06-29 19:08:44 +02:00
|
|
|
/* ResidualVM - A 3D game interpreter
|
2012-01-06 22:56:21 +01:00
|
|
|
*
|
2019-06-29 19:08:44 +02:00
|
|
|
* ResidualVM is the legal property of its developers, whose names
|
2012-01-06 22:56:21 +01:00
|
|
|
* 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.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2012-01-06 22:56:21 +01:00
|
|
|
* 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.
|
2014-04-05 18:18:42 +02:00
|
|
|
*
|
2012-01-06 22:56:21 +01:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "backends/graphics/sdl/sdl-graphics.h"
|
|
|
|
|
2015-04-19 07:43:34 +02:00
|
|
|
#include "backends/platform/sdl/sdl-sys.h"
|
2012-01-06 22:56:21 +01:00
|
|
|
#include "backends/events/sdl/sdl-events.h"
|
2015-04-19 07:43:34 +02:00
|
|
|
#include "common/textconsole.h"
|
2012-01-06 22:56:21 +01:00
|
|
|
|
2015-04-19 07:43:34 +02:00
|
|
|
SdlGraphicsManager::SdlGraphicsManager(SdlEventSource *source, SdlWindow *window)
|
|
|
|
: _eventSource(source), _window(window) {
|
2012-01-06 22:56:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
SdlGraphicsManager::~SdlGraphicsManager() {
|
|
|
|
}
|
|
|
|
|
2014-01-25 22:16:57 +01:00
|
|
|
void SdlGraphicsManager::activateManager() {
|
2013-12-08 13:25:24 +01:00
|
|
|
_eventSource->setGraphicsManager(this);
|
|
|
|
}
|
|
|
|
|
2014-01-25 22:16:57 +01:00
|
|
|
void SdlGraphicsManager::deactivateManager() {
|
2013-12-08 13:25:24 +01:00
|
|
|
_eventSource->setGraphicsManager(0);
|
|
|
|
}
|
2015-04-19 07:43:34 +02:00
|
|
|
|
2017-12-03 18:33:19 +01:00
|
|
|
SdlGraphicsManager::State SdlGraphicsManager::getState() const {
|
2015-04-19 07:43:34 +02:00
|
|
|
State state;
|
|
|
|
|
|
|
|
state.screenWidth = getWidth();
|
|
|
|
state.screenHeight = getHeight();
|
|
|
|
state.aspectRatio = getFeatureState(OSystem::kFeatureAspectRatioCorrection);
|
|
|
|
state.fullscreen = getFeatureState(OSystem::kFeatureFullscreenMode);
|
|
|
|
state.cursorPalette = getFeatureState(OSystem::kFeatureCursorPalette);
|
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
state.pixelFormat = getScreenFormat();
|
|
|
|
#endif
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SdlGraphicsManager::setState(const State &state) {
|
|
|
|
beginGFXTransaction();
|
|
|
|
#ifdef USE_RGB_COLOR
|
|
|
|
initSize(state.screenWidth, state.screenHeight, &state.pixelFormat);
|
|
|
|
#else
|
2017-12-03 18:33:19 +01:00
|
|
|
initSize(state.screenWidth, state.screenHeight, nullptr);
|
2015-04-19 07:43:34 +02:00
|
|
|
#endif
|
|
|
|
setFeatureState(OSystem::kFeatureAspectRatioCorrection, state.aspectRatio);
|
|
|
|
setFeatureState(OSystem::kFeatureFullscreenMode, state.fullscreen);
|
|
|
|
setFeatureState(OSystem::kFeatureCursorPalette, state.cursorPalette);
|
|
|
|
|
|
|
|
if (endGFXTransaction() != OSystem::kTransactionSuccess) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|