Skip to content

Commit 92d57d5

Browse files
committed
don't init Screen as 32bpp if wrong mode for HQX
1 parent 8eaf49b commit 92d57d5

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎src/Engine/Game.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Game::Game(const std::string &title) : _screen(0), _cursor(0), _lang(0), _states
109109
SDL_EnableUNICODE(1);
110110

111111
// Create display
112-
int bpp = Options::getBool("useHQXFilter") ? 32 : 8;
112+
int bpp = Screen::isHQXEnabled() ? 32 : 8;
113113
_screen = new Screen(Options::getInt("displayWidth"), Options::getInt("displayHeight"), bpp, Options::getBool("fullscreen"));
114114

115115
// Create cursor

‎src/Engine/Screen.cpp‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,4 +336,24 @@ void Screen::screenshot(const std::string &filename) const
336336
}
337337
}
338338

339+
340+
/** Check whether useHQXFilter is set in Options and a compatible resolution
341+
* has been selected.
342+
*/
343+
bool Screen::isHQXEnabled()
344+
{
345+
int w = Options::getInt("displayWidth");
346+
int h = Options::getInt("displayHeight");
347+
348+
if (Options::getBool("useHQXFilter") && (
349+
(w == Screen::BASE_WIDTH * 2 && h == Screen::BASE_HEIGHT * 2) ||
350+
(w == Screen::BASE_WIDTH * 3 && h == Screen::BASE_HEIGHT * 3) ||
351+
(w == Screen::BASE_WIDTH * 4 && h == Screen::BASE_HEIGHT * 4)))
352+
{
353+
return true;
354+
}
355+
356+
return false;
357+
}
358+
339359
}

‎src/Engine/Screen.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class Screen
8282
double getYScale() const;
8383
/// Takes a screenshot.
8484
void screenshot(const std::string &filename) const;
85+
/// Checks whether HQX is requested and works for the selected resolution
86+
static bool isHQXEnabled();
8587
};
8688

8789
}

0 commit comments

Comments
 (0)