Skip to content

Commit

Permalink
ENGINES: Use common GFX code for 3D games - fixes part of bug #14342
Browse files Browse the repository at this point in the history
Now, when the launcher is in full screen, the game will also be in full
screen. However, when returning to the launcher, graphics are reset to
default with a setupGraphics() call. Thus, if the user hasn't selected
full screen display in the options, but only used alt-enter to change
the launcher to full screen, the launcher will return to window mode.
  • Loading branch information
bluegr committed Nov 19, 2024
1 parent ebfef70 commit 1bc59d5
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions engines/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,36 +237,42 @@ void initCommonGFX() {
// Any global or command line settings already have been applied at the time
// we get here, so we only do something if the game domain overrides those
// values
if (gameDomain) {
if (gameDomain->contains("aspect_ratio"))
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));
if (!gameDomain)
return;

if (gameDomain->contains("aspect_ratio"))
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio"));

if (gameDomain->contains("fullscreen"))
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));

if (gameDomain->contains("fullscreen"))
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen"));
if (gameDomain->contains("vsync"))
g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync"));

if (gameDomain->contains("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));
if (gameDomain->contains("stretch_mode"))
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());

if (gameDomain->contains("vsync"))
g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync"));
// Stop here for hardware-accelerated 3D games
if (g_system->hasFeature(OSystem::kFeatureOpenGLForGame))
return;

if (gameDomain->contains("stretch_mode"))
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str());
// Set up filtering, scaling and shaders for 2D games
if (gameDomain->contains("filtering"))
g_system->setFeatureState(OSystem::kFeatureFilteringMode, ConfMan.getBool("filtering"));

if (gameDomain->contains("scaler") || gameDomain->contains("scale_factor"))
g_system->setScaler(ConfMan.get("scaler").c_str(), ConfMan.getInt("scale_factor"));
if (gameDomain->contains("scaler") || gameDomain->contains("scale_factor"))
g_system->setScaler(ConfMan.get("scaler").c_str(), ConfMan.getInt("scale_factor"));

if (gameDomain->contains("shader"))
g_system->setShader(ConfMan.getPath("shader"));
if (gameDomain->contains("shader"))
g_system->setShader(ConfMan.getPath("shader"));

// TODO: switching between OpenGL and SurfaceSDL is quite fragile
// and the SDL backend doesn't really need this so leave it out
// for now to avoid regressions
// TODO: switching between OpenGL and SurfaceSDL is quite fragile
// and the SDL backend doesn't really need this so leave it out
// for now to avoid regressions
#ifndef SDL_BACKEND
if (gameDomain->contains("gfx_mode"))
g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
if (gameDomain->contains("gfx_mode"))
g_system->setGraphicsMode(ConfMan.get("gfx_mode").c_str());
#endif
}
}

// Please leave the splash screen in working order for your releases, even if they're commercial.
Expand Down Expand Up @@ -486,11 +492,8 @@ void initGraphics(int width, int height) {
void initGraphics3d(int width, int height) {
g_system->beginGFXTransaction();
g_system->setGraphicsMode(0, OSystem::kGfxModeRender3d);
initCommonGFX();
g_system->initSize(width, height);
g_system->setFeatureState(OSystem::kFeatureFullscreenMode, ConfMan.getBool("fullscreen")); // TODO: Replace this with initCommonGFX()
g_system->setFeatureState(OSystem::kFeatureAspectRatioCorrection, ConfMan.getBool("aspect_ratio")); // TODO: Replace this with initCommonGFX()
g_system->setFeatureState(OSystem::kFeatureVSync, ConfMan.getBool("vsync")); // TODO: Replace this with initCommonGFX()
g_system->setStretchMode(ConfMan.get("stretch_mode").c_str()); // TODO: Replace this with initCommonGFX()
g_system->endGFXTransaction();

if (!splash && !GUI::GuiManager::instance()._launched) {
Expand Down

0 comments on commit 1bc59d5

Please sign in to comment.