Skip to content

Commit

Permalink
Enforce a sane minimum window size and resolution
Browse files Browse the repository at this point in the history
See: crash report #444
  • Loading branch information
dscharrer committed Jan 26, 2013
1 parent 818a67e commit 04619c6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/ArxGame.cpp
Expand Up @@ -260,10 +260,18 @@ void ArxGame::setFullscreen(bool fullscreen) {
mode = GetWindow()->getDisplayModes().back();
}

// Clamp to a sane resolution!
mode.resolution.x = std::max(mode.resolution.x, s32(640));
mode.resolution.y = std::max(mode.resolution.y, s32(480));

GetWindow()->setFullscreenMode(mode.resolution, mode.depth);

} else {

// Clamp to a sane window size!
config.window.size.x = std::max(config.window.size.x, s32(640));
config.window.size.y = std::max(config.window.size.y, s32(480));

GetWindow()->setWindowSize(config.window.size);

}
Expand Down Expand Up @@ -309,6 +317,12 @@ bool ArxGame::initWindow(RenderWindow * window) {

}

// Clamp to a sane resolution and window size!
mode.resolution.x = std::max(mode.resolution.x, s32(640));
mode.resolution.y = std::max(mode.resolution.y, s32(480));
config.window.size.x = std::max(config.window.size.x, s32(640));
config.window.size.y = std::max(config.window.size.y, s32(480));

Vec2i size = config.video.fullscreen ? mode.resolution : config.window.size;

if(!m_MainWindow->init(version, size, config.video.fullscreen, mode.depth)) {
Expand Down Expand Up @@ -519,6 +533,8 @@ void ArxGame::OnWindowLostFocus(const Window &) {

void ArxGame::OnResizeWindow(const Window & window) {

arx_assert(window.GetSize() != Vec2i::ZERO);

// A new window size will require a new backbuffer
// size, so the 3D structures must be changed accordingly.
wasResized = true;
Expand Down

0 comments on commit 04619c6

Please sign in to comment.