ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

resvm-sdl-graphics.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "backends/graphics/sdl/resvm-sdl-graphics.h"
00024 
00025 #include "backends/platform/sdl/sdl-sys.h"
00026 #include "backends/events/sdl/sdl-events.h"
00027 
00028 #include "common/config-manager.h"
00029 #include "common/textconsole.h"
00030 
00031 static const OSystem::GraphicsMode s_supportedGraphicsModes[] = {
00032         {0, 0, 0}
00033 };
00034 
00035 ResVmSdlGraphicsManager::ResVmSdlGraphicsManager(SdlEventSource *source, SdlWindow *window, const Capabilities &capabilities) :
00036         SdlGraphicsManager(source, window),
00037         _fullscreen(false),
00038         _lockAspectRatio(true),
00039         _overlayVisible(false),
00040         _screenChangeCount(0),
00041         _capabilities(capabilities),
00042         _engineRequestedWidth(0),
00043         _engineRequestedHeight(0)  {
00044     ConfMan.registerDefault("fullscreen_res", "desktop");
00045     ConfMan.registerDefault("aspect_ratio", true);
00046     ConfMan.registerDefault("vsync", true);
00047 }
00048 
00049 ResVmSdlGraphicsManager::~ResVmSdlGraphicsManager() {
00050 }
00051 
00052 void ResVmSdlGraphicsManager::activateManager() {
00053     SdlGraphicsManager::activateManager();
00054 
00055     // Register the graphics manager as a event observer
00056     g_system->getEventManager()->getEventDispatcher()->registerObserver(this, 10, false);
00057 }
00058 
00059 void ResVmSdlGraphicsManager::deactivateManager() {
00060     // Unregister the event observer
00061     if (g_system->getEventManager()->getEventDispatcher()) {
00062         g_system->getEventManager()->getEventDispatcher()->unregisterObserver(this);
00063     }
00064 
00065     SdlGraphicsManager::deactivateManager();
00066 }
00067 
00068 Common::Rect ResVmSdlGraphicsManager::getPreferredFullscreenResolution() {
00069     // Default to the desktop resolution ...
00070     uint preferredWidth = _capabilities.desktopWidth;
00071     uint preferredHeight = _capabilities.desktopHeight;
00072 
00073     // ... unless the user has set a resolution in the configuration file
00074     const Common::String &fsres = ConfMan.get("fullscreen_res");
00075     if (fsres != "desktop") {
00076         uint newW, newH;
00077         int converted = sscanf(fsres.c_str(), "%ux%u", &newW, &newH);
00078         if (converted == 2) {
00079             preferredWidth = newW;
00080             preferredHeight = newH;
00081         } else {
00082             warning("Could not parse 'fullscreen_res' option: expected WWWxHHH, got %s", fsres.c_str());
00083         }
00084     }
00085 
00086     return Common::Rect(preferredWidth, preferredHeight);
00087 }
00088 
00089 void ResVmSdlGraphicsManager::resetGraphicsScale() {
00090     setGraphicsMode(0);
00091 }
00092 
00093 void ResVmSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) {
00094     switch (f) {
00095         case OSystem::kFeatureAspectRatioCorrection:
00096             _lockAspectRatio = enable;
00097             break;
00098         default:
00099             break;
00100     }
00101 }
00102 
00103 bool ResVmSdlGraphicsManager::getFeatureState(OSystem::Feature f) const {
00104     switch (f) {
00105         case OSystem::kFeatureFullscreenMode:
00106             return _fullscreen;
00107         case OSystem::kFeatureAspectRatioCorrection:
00108             return _lockAspectRatio;
00109         default:
00110             return false;
00111     }
00112 }
00113 
00114 const OSystem::GraphicsMode *ResVmSdlGraphicsManager::getSupportedGraphicsModes() const {
00115     return s_supportedGraphicsModes;
00116 }
00117 
00118 int ResVmSdlGraphicsManager::getDefaultGraphicsMode() const {
00119     return 0;// ResidualVM: not use it
00120 }
00121 
00122 void ResVmSdlGraphicsManager::beginGFXTransaction() {
00123     // ResidualVM: not use it
00124 }
00125 
00126 OSystem::TransactionError ResVmSdlGraphicsManager::endGFXTransaction() {
00127     // ResidualVM: not use it
00128     return OSystem::kTransactionSuccess;
00129 }
00130 
00131 #ifdef USE_RGB_COLOR
00132 Common::List<Graphics::PixelFormat> ResVmSdlGraphicsManager::getSupportedFormats() const {
00133     // ResidualVM: not use it
00134     return _supportedFormats;
00135 }
00136 #endif
00137 
00138 bool ResVmSdlGraphicsManager::setGraphicsMode(int mode) {
00139     // ResidualVM: not use it
00140     return true;
00141 }
00142 
00143 int ResVmSdlGraphicsManager::getGraphicsMode() const {
00144     // ResidualVM: not use it
00145     return 0;
00146 }
00147 
00148 void ResVmSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) {
00149     // ResidualVM: not use it
00150 }
00151 
00152 void ResVmSdlGraphicsManager::copyRectToScreen(const void *src, int pitch, int x, int y, int w, int h) {
00153     // ResidualVM: not use it
00154 }
00155 
00156 Graphics::Surface *ResVmSdlGraphicsManager::lockScreen() {
00157     return NULL; // ResidualVM: not use it
00158 }
00159 
00160 void ResVmSdlGraphicsManager::unlockScreen() {
00161     // ResidualVM: not use it
00162 }
00163 
00164 void ResVmSdlGraphicsManager::fillScreen(uint32 col) {
00165     // ResidualVM: not use it
00166 }
00167 
00168 void ResVmSdlGraphicsManager::setPalette(const byte *colors, uint start, uint num) {
00169     // ResidualVM: not use it
00170 }
00171 
00172 void ResVmSdlGraphicsManager::grabPalette(byte *colors, uint start, uint num) const {
00173     // ResidualVM: not use it
00174 }
00175 
00176 void ResVmSdlGraphicsManager::setCursorPalette(const byte *colors, uint start, uint num) {
00177     // ResidualVM: not use it
00178 }
00179 
00180 void ResVmSdlGraphicsManager::setShakePos(int shake_pos) {
00181     // ResidualVM: not use it
00182 }
00183 
00184 void ResVmSdlGraphicsManager::setFocusRectangle(const Common::Rect &rect) {
00185     // ResidualVM: not use it
00186 }
00187 
00188 void ResVmSdlGraphicsManager::clearFocusRectangle() {
00189     // ResidualVM: not use it
00190 }
00191 
00192 #pragma mark -
00193 #pragma mark --- Mouse ---
00194 #pragma mark -
00195 
00196 bool ResVmSdlGraphicsManager::showMouse(bool visible) {
00197     SDL_ShowCursor(visible);
00198     return true;
00199 }
00200 
00201 bool ResVmSdlGraphicsManager::lockMouse(bool lock) {
00202 #if SDL_VERSION_ATLEAST(2, 0, 0)
00203     if (lock)
00204         SDL_SetRelativeMouseMode(SDL_TRUE);
00205     else
00206         SDL_SetRelativeMouseMode(SDL_FALSE);
00207 #else
00208     if (lock)
00209         SDL_WM_GrabInput(SDL_GRAB_ON);
00210     else
00211         SDL_WM_GrabInput(SDL_GRAB_OFF);
00212 #endif
00213     return true;
00214 }
00215 
00216 bool ResVmSdlGraphicsManager::isMouseLocked() const {
00217 #if SDL_VERSION_ATLEAST(2, 0, 0)
00218     return SDL_GetRelativeMouseMode() == SDL_TRUE;
00219 #else
00220     return SDL_GrabMode() == SDL_GRAB_ON;
00221 #endif
00222 }
00223 
00224 void ResVmSdlGraphicsManager::setMouseCursor(const void *buf, uint w, uint h, int hotspot_x, int hotspot_y, uint32 keycolor, bool dontScale, const Graphics::PixelFormat *format) {
00225     // ResidualVM: not use it
00226 }
00227 
00228 #pragma mark -
00229 #pragma mark --- On Screen Display ---
00230 #pragma mark -
00231 
00232 #ifdef USE_OSD
00233 void OpenGLResVmSdlGraphicsManager::displayMessageOnOSD(const char *msg) {
00234     // ResidualVM: not use it
00235 }
00236 #endif
00237 
00238 bool ResVmSdlGraphicsManager::notifyEvent(const Common::Event &event) {
00239     //ResidualVM specific:
00240     switch ((int)event.type) {
00241         case Common::EVENT_KEYDOWN:
00242             break;
00243         case Common::EVENT_KEYUP:
00244             break;
00245         default:
00246             break;
00247     }
00248 
00249     return false;
00250 }
00251 
00252 void ResVmSdlGraphicsManager::notifyVideoExpose() {
00253     //ResidualVM specific:
00254     //updateScreen();
00255 }
00256 
00257 bool ResVmSdlGraphicsManager::notifyMousePosition(Common::Point mouse) {
00258     transformMouseCoordinates(mouse);
00259     // ResidualVM: not use that:
00260     //setMousePos(mouse.x, mouse.y);
00261     return true;
00262 }


Generated on Sat Feb 23 2019 05:01:15 for ResidualVM by doxygen 1.7.1
curved edge   curved edge