SDL: Support auto-detection of GUI resolution.

This commit is contained in:
Vladimir Serbinenko 2023-01-05 13:22:55 +01:00
parent 47ab3fe4fc
commit b91d873df6
3 changed files with 38 additions and 0 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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"));