diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index dc787ebcf1..02c0dd87d3 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -16,7 +16,6 @@ namespace openage::engine { Engine::Engine(mode mode, const util::Path &root_dir, const std::vector &mods, - bool debug_graphics, const renderer::window_settings &window_settings) : running{true}, run_mode{mode}, @@ -56,8 +55,8 @@ Engine::Engine(mode mode, // if presenter is used, run it in a separate thread if (this->run_mode == mode::FULL) { - this->threads.emplace_back([&, debug_graphics]() { - this->presenter->run(debug_graphics, window_settings); + this->threads.emplace_back([&]() { + this->presenter->run(window_settings); // Make sure that the presenter gets destructed in the same thread // otherwise OpenGL complains about missing contexts diff --git a/libopenage/engine/engine.h b/libopenage/engine/engine.h index d324fe4fda..0231054628 100644 --- a/libopenage/engine/engine.h +++ b/libopenage/engine/engine.h @@ -7,9 +7,9 @@ #include #include +#include "renderer/window.h" #include "util/path.h" -#include // TODO: Remove custom jthread definition when clang/libc++ finally supports it #if __llvm__ @@ -73,13 +73,11 @@ class Engine { * @param mode The run mode to use. * @param root_dir openage root directory. * @param mods The mods to load. - * @param debug_graphics If true, enable OpenGL debug logging. - * @param window_settings window display setting + * @param window_settings The settings to customize the display window (e.g. size, display mode, vsync). */ Engine(mode mode, const util::Path &root_dir, const std::vector &mods, - bool debug_graphics = false, const renderer::window_settings &window_settings = {}); // engine should not be copied or moved diff --git a/libopenage/main.cpp b/libopenage/main.cpp index f8e6b45f3f..2147cbe4e0 100644 --- a/libopenage/main.cpp +++ b/libopenage/main.cpp @@ -44,12 +44,16 @@ int run_game(const main_arguments &args) { else if (args.window_args.mode == "borderless") { wmode = renderer::window_mode::BORDERLESS; } - else { + else if (args.window_args.mode == "windowed") { wmode = renderer::window_mode::WINDOWED; } + else { + throw Error(MSG(err) << "Invalid window mode: " << args.window_args.mode); + } win_settings.mode = wmode; + win_settings.debug = args.gl_debug; - openage::engine::Engine engine{run_mode, args.root_path, args.mods, args.gl_debug, win_settings}; + openage::engine::Engine engine{run_mode, args.root_path, args.mods, win_settings}; engine.loop(); diff --git a/libopenage/presenter/presenter.cpp b/libopenage/presenter/presenter.cpp index 6d77a72710..6db1e23136 100644 --- a/libopenage/presenter/presenter.cpp +++ b/libopenage/presenter/presenter.cpp @@ -47,10 +47,10 @@ Presenter::Presenter(const util::Path &root_dir, time_loop{time_loop} {} -void Presenter::run(bool debug_graphics, const renderer::window_settings &window_settings) { +void Presenter::run(const renderer::window_settings &window_settings) { log::log(INFO << "Presenter: Launching subsystems..."); - this->init_graphics(debug_graphics, window_settings); + this->init_graphics(window_settings); this->init_input(); @@ -92,7 +92,7 @@ std::shared_ptr Presenter::init_window_system() { return std::make_shared(); } -void Presenter::init_graphics(bool debug, const renderer::window_settings &window_settings) { +void Presenter::init_graphics(const renderer::window_settings &window_settings) { log::log(INFO << "Presenter: Initializing graphics subsystems..."); // Start up rendering framework diff --git a/libopenage/presenter/presenter.h b/libopenage/presenter/presenter.h index 6f45800a32..a4b5dec68e 100644 --- a/libopenage/presenter/presenter.h +++ b/libopenage/presenter/presenter.h @@ -5,10 +5,9 @@ #include #include +#include "renderer/window.h" #include "util/path.h" -#include - namespace qtgui { class GuiApplication; @@ -90,10 +89,9 @@ class Presenter { /** * Start the presenter and initialize subsystems. * - * @param debug_graphics If true, enable OpenGL debug logging. - * @param window_settings window display setting + * @param window_settings The settings to customize the display window (e.g. size, display mode, vsync). */ - void run(bool debug_graphics = false, const renderer::window_settings &window_settings = {}); + void run(const renderer::window_settings &window_settings = {}); /** * Set the game simulation controlled by this presenter. @@ -124,7 +122,7 @@ class Presenter { * - main renderer * - component renderers (Terrain, Game Entities, GUI) */ - void init_graphics(bool debug = false, const renderer::window_settings &window_settings = {}); + void init_graphics(const renderer::window_settings &window_settings = {}); /** * Initialize the GUI. diff --git a/libopenage/renderer/opengl/window.cpp b/libopenage/renderer/opengl/window.cpp index d832c49337..46772e14d9 100644 --- a/libopenage/renderer/opengl/window.cpp +++ b/libopenage/renderer/opengl/window.cpp @@ -58,18 +58,20 @@ GlWindow::GlWindow(const std::string &title, this->window->create(); // set display mode + // Reset to a known state + this->window->setWindowState(Qt::WindowNoState); switch (settings.mode) { - case window_mode::FULLSCREEN: - this->window->showFullScreen(); + case window_mode::WINDOWED: + this->window->setFlags(this->window->flags() & ~Qt::FramelessWindowHint); break; case window_mode::BORDERLESS: this->window->setFlags(this->window->flags() | Qt::FramelessWindowHint); - this->window->show(); break; - case window_mode::WINDOWED: - default: - this->window->showNormal(); + case window_mode::FULLSCREEN: + this->window->setWindowState(Qt::WindowFullScreen); break; + default: + throw Error{MSG(err) << "Invalid window mode."}; } this->context = std::make_shared(this->window, settings.debug); diff --git a/libopenage/renderer/window.h b/libopenage/renderer/window.h index 6f34aa58e3..e3465bef4d 100644 --- a/libopenage/renderer/window.h +++ b/libopenage/renderer/window.h @@ -45,7 +45,7 @@ struct window_settings { // If true, enable debug logging for the selected backend. bool debug = false; // Display mode for the window. - window_mode mode = window_mode::FULLSCREEN; + window_mode mode = window_mode::WINDOWED; }; diff --git a/openage/game/main.py b/openage/game/main.py index 44b74ee058..1ad1378426 100644 --- a/openage/game/main.py +++ b/openage/game/main.py @@ -39,15 +39,15 @@ def init_subparser(cli: ArgumentParser) -> None: cli.add_argument( "--window-size", nargs=2, type=int, default=[1024, 768], metavar=('WIDTH', 'HEIGHT'), - help="initial window size in pixels, e.g., --window-size 1024 768") + help="Initial window size in pixels") cli.add_argument( "--vsync", action='store_true', - help="enable vertical synchronization") + help="Enable vertical synchronization") cli.add_argument( "--window-mode", choices=["fullscreen", "borderless", "windowed"], default="windowed", - help="set the window mode: fullscreen, borderless, or windowed (default)") + help="Set the window mode") def main(args, error): diff --git a/openage/main/main.py b/openage/main/main.py index 5fa628c3e5..05266ec744 100644 --- a/openage/main/main.py +++ b/openage/main/main.py @@ -31,15 +31,15 @@ def init_subparser(cli: ArgumentParser): cli.add_argument( "--window-size", nargs=2, type=int, default=[1024, 768], metavar=('WIDTH', 'HEIGHT'), - help="initial window size in pixels, e.g., --window-size 1024 768") + help="Initial window size in pixels") cli.add_argument( "--vsync", action='store_true', - help="enable vertical synchronization") + help="Enable vertical synchronization") cli.add_argument( "--window-mode", choices=["fullscreen", "borderless", "windowed"], default="windowed", - help="set the window mode: fullscreen, borderless, or windowed (default)") + help="Set the window mode") def main(args, error):