diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp index f8e5e2c7535..2c49108c6b8 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp @@ -707,12 +707,42 @@ int SurfaceSdlGraphicsManager::getStretchMode() const { } #endif +void SurfaceSdlGraphicsManager::getDefaultResolution(uint &w, uint &h) { +#ifdef RS90 + SDL_PixelFormat p; + p.BitsPerPixel = 16; + p.BytesPerPixel = 2; + p.Rloss = 3; + p.Gloss = 2; + p.Bloss = 3; + p.Rshift = 11; + p.Gshift = 5; + p.Bshift = 0; + p.Rmask = 0xf800; + p.Gmask = 0x07e0; + p.Bmask = 0x001f; + p.colorkey = 0; + p.alpha = 0; + // Only native screen resolution is supported in RGB565 fullscreen hwsurface. + SDL_Rect const* const*availableModes = SDL_ListModes(&p, SDL_FULLSCREEN|SDL_HWSURFACE); + w = availableModes[0]->w; + h = availableModes[0]->h; +#else + w = 320; + h = 200; +#endif +} + void SurfaceSdlGraphicsManager::initSize(uint w, uint h, const Graphics::PixelFormat *format) { assert(_transactionMode == kTransactionActive); _gameScreenShakeXOffset = 0; _gameScreenShakeYOffset = 0; + if (w == 0) { + getDefaultResolution(w, h); + } + #ifdef USE_RGB_COLOR //avoid redundant format changes Graphics::PixelFormat newFormat; diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.h b/backends/graphics/surfacesdl/surfacesdl-graphics.h index 3b039898358..b09d709836c 100644 --- a/backends/graphics/surfacesdl/surfacesdl-graphics.h +++ b/backends/graphics/surfacesdl/surfacesdl-graphics.h @@ -428,6 +428,7 @@ protected: bool saveScreenshot(const Common::String &filename) const override; virtual void setGraphicsModeIntern(); + void getDefaultResolution(uint &w, uint &h); private: void setFullscreenMode(bool enable); diff --git a/base/main.cpp b/base/main.cpp index 19534c84530..e5fc9315541 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -351,7 +351,14 @@ static void setupGraphics(OSystem &system) { system.setScaler(ConfMan.get("scaler").c_str(), ConfMan.getInt("scale_factor")); system.setShader(ConfMan.get("shader")); +#ifdef OPENDINGUX + // 0, 0 means "autodetect" but currently only SDL supports + // it and really useful only on Opendingux. When more platforms + // support it we will switch to it. + system.initSize(0, 0); +#else system.initSize(320, 200); +#endif // Parse graphics configuration, implicit fallback to defaults set with RegisterDefaults() system.setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));