From d2e4d93828ddc82e660eb1a1e75b3d85fc782c42 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 16:24:50 -0500 Subject: [PATCH 1/8] Added custom resolution size for main and game Signed-off-by: Raul Galvez --- libopenage/engine/engine.cpp | 14 ++++++++++---- libopenage/engine/engine.h | 16 +++++++++++++++- libopenage/main.cpp | 2 +- libopenage/main.h | 4 ++++ libopenage/presenter/presenter.cpp | 6 +++--- libopenage/presenter/presenter.h | 6 ++++-- openage/game/main.py | 12 ++++++++++-- openage/game/main_cpp.pyx | 12 ++++++++++++ openage/main/main.py | 9 +++++++++ openage/main/main_cpp.pyx | 12 ++++++++++++ 10 files changed, 80 insertions(+), 13 deletions(-) diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index fa2c251b4d..6996b05dfb 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -16,14 +16,20 @@ namespace openage::engine { Engine::Engine(mode mode, const util::Path &root_dir, const std::vector &mods, - bool debug_graphics) : + bool debug_graphics, + int wWidth, + int wHeight) : running{true}, run_mode{mode}, root_dir{root_dir}, - threads{} { + threads{}, + width{wWidth}, + height{wHeight}, { log::log(INFO << "launching engine with root directory" - << root_dir); + << root_dir + <<"width: " << width + <<"height: " << height); // read and apply the configuration files this->cvar_manager = std::make_shared(this->root_dir["cfg"]); @@ -56,7 +62,7 @@ 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); + this->presenter->run(debug_graphics, width, height); // 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 4f96ae74bf..537fb3b6f9 100644 --- a/libopenage/engine/engine.h +++ b/libopenage/engine/engine.h @@ -72,11 +72,15 @@ class Engine { * @param root_dir openage root directory. * @param mods The mods to load. * @param debug_graphics If true, enable OpenGL debug logging. + * @param wWidth Width of the window. + * @param wHeight Height of the window. */ Engine(mode mode, const util::Path &root_dir, const std::vector &mods, - bool debug_graphics = false); + bool debug_graphics = false, + int wWidth = 1024, + int wHeight = 768); // engine should not be copied or moved Engine(const Engine &) = delete; @@ -108,6 +112,16 @@ class Engine { */ util::Path root_dir; + /** + * The width of the rendering window. + */ + int width; + + /** + * The height of the rendering window. + */ + int height; + /** * The threads used by the engine. */ diff --git a/libopenage/main.cpp b/libopenage/main.cpp index e7794be40c..813de85fb6 100644 --- a/libopenage/main.cpp +++ b/libopenage/main.cpp @@ -31,7 +31,7 @@ int run_game(const main_arguments &args) { run_mode = openage::engine::Engine::mode::HEADLESS; } - openage::engine::Engine engine{run_mode, args.root_path, args.mods, args.gl_debug}; + openage::engine::Engine engine{run_mode, args.root_path, args.mods, args.gl_debug, args.width, args.height}; engine.loop(); diff --git a/libopenage/main.h b/libopenage/main.h index 0e60c386cc..c4d8ff0e00 100644 --- a/libopenage/main.h +++ b/libopenage/main.h @@ -26,12 +26,16 @@ namespace openage { * bool gl_debug * bool headless * vector[string] mods + * int width + * int height */ struct main_arguments { util::Path root_path; bool gl_debug; bool headless; std::vector mods; + int width; + int height; }; diff --git a/libopenage/presenter/presenter.cpp b/libopenage/presenter/presenter.cpp index 62435074d4..ec3a84e321 100644 --- a/libopenage/presenter/presenter.cpp +++ b/libopenage/presenter/presenter.cpp @@ -48,10 +48,10 @@ Presenter::Presenter(const util::Path &root_dir, time_loop{time_loop} {} -void Presenter::run(bool debug_graphics) { +void Presenter::run(bool debug_graphics, int width, int height) { log::log(INFO << "Presenter: Launching subsystems..."); - this->init_graphics(debug_graphics); + this->init_graphics(debug_graphics, width, height); this->init_input(); @@ -93,7 +93,7 @@ std::shared_ptr Presenter::init_window_system() { return std::make_shared(); } -void Presenter::init_graphics(bool debug) { +void Presenter::init_graphics(int width, int height, bool debug) { log::log(INFO << "Presenter: Initializing graphics subsystems..."); // Start up rendering framework diff --git a/libopenage/presenter/presenter.h b/libopenage/presenter/presenter.h index b43d4fc60f..a6ece3aa86 100644 --- a/libopenage/presenter/presenter.h +++ b/libopenage/presenter/presenter.h @@ -88,8 +88,10 @@ class Presenter { * Start the presenter and initialize subsystems. * * @param debug_graphics If true, enable OpenGL debug logging. + * @param width Width of the window rendered. + * @param height height of the window rendered. */ - void run(bool debug_graphics = false); + void run(bool debug_graphics = false, int width = 1024, int height = 768); /** * Set the game simulation controlled by this presenter. @@ -120,7 +122,7 @@ class Presenter { * - main renderer * - component renderers (Terrain, Game Entities, GUI) */ - void init_graphics(bool debug = false); + void init_graphics(bool debug = false, int width = 1024, int height = 768); /** * Initialize the GUI. diff --git a/openage/game/main.py b/openage/game/main.py index 0fdf007259..e42fb81a93 100644 --- a/openage/game/main.py +++ b/openage/game/main.py @@ -33,9 +33,17 @@ def init_subparser(cli: ArgumentParser) -> None: cli.add_argument( "--check-updates", action='store_true', - help="Check if the assets are up to date" - ) + help="Check if the assets are up to date") + + cli.add_argument( + "--width", type=int, default=None, + help="width of the game window") + cli.add_argument( + "--height", type=int, default=None, + help="height of the game window" + ) + def main(args, error): """ diff --git a/openage/game/main_cpp.pyx b/openage/game/main_cpp.pyx index e7697b0ddb..5863ebbcf0 100644 --- a/openage/game/main_cpp.pyx +++ b/openage/game/main_cpp.pyx @@ -37,6 +37,18 @@ def run_game(args, root_path): else: args_cpp.mods = vector[string]() + # window width + if args.width is not None: + args_cpp.width = args.width + else: + args_cpp.width = 1024 + + # window height + if args.height is not None: + args_cpp.height = args.height + else: + args_cpp.height = 768 + # run the game! with nogil: result = run_game_cpp(args_cpp) diff --git a/openage/main/main.py b/openage/main/main.py index fbeb527ee4..5bb328a518 100644 --- a/openage/main/main.py +++ b/openage/main/main.py @@ -28,6 +28,15 @@ def init_subparser(cli: ArgumentParser): "--modpacks", nargs="+", type=str, help="list of modpacks to load") + cli.add_argument( + "--width", type=int, default=None, + help="width of the game window") + + cli.add_argument( + "--height", type=int, default=None, + help="height of the game window" + ) + def main(args, error): """ diff --git a/openage/main/main_cpp.pyx b/openage/main/main_cpp.pyx index e7697b0ddb..5863ebbcf0 100644 --- a/openage/main/main_cpp.pyx +++ b/openage/main/main_cpp.pyx @@ -37,6 +37,18 @@ def run_game(args, root_path): else: args_cpp.mods = vector[string]() + # window width + if args.width is not None: + args_cpp.width = args.width + else: + args_cpp.width = 1024 + + # window height + if args.height is not None: + args_cpp.height = args.height + else: + args_cpp.height = 768 + # run the game! with nogil: result = run_game_cpp(args_cpp) From 380927b5f03d22f86cd650103d7083e9869e3dde Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 18:11:23 -0500 Subject: [PATCH 2/8] Fixed syntax errors in engine.cpp lines 27, 31, 32 Signed-off-by: Raul Galvez --- libopenage/engine/engine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index 6996b05dfb..f5694c47db 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -24,12 +24,12 @@ Engine::Engine(mode mode, root_dir{root_dir}, threads{}, width{wWidth}, - height{wHeight}, { + height{wHeight} { log::log(INFO << "launching engine with root directory" << root_dir - <<"width: " << width - <<"height: " << height); + << "width: " << width + << "height: " << height); // read and apply the configuration files this->cvar_manager = std::make_shared(this->root_dir["cfg"]); From a4f98f4bf974a3a89664bda98233fd9d992c5249 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 18:25:49 -0500 Subject: [PATCH 3/8] Removed trailing whitespace and fixed init_graphics parameter order declaration --- libopenage/engine/engine.cpp | 4 ++-- libopenage/presenter/presenter.cpp | 2 +- openage/game/main.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index f5694c47db..bdc1fac61c 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -22,9 +22,9 @@ Engine::Engine(mode mode, running{true}, run_mode{mode}, root_dir{root_dir}, - threads{}, + height{wHeight}, width{wWidth}, - height{wHeight} { + threads{} { log::log(INFO << "launching engine with root directory" << root_dir diff --git a/libopenage/presenter/presenter.cpp b/libopenage/presenter/presenter.cpp index ec3a84e321..4be3a54043 100644 --- a/libopenage/presenter/presenter.cpp +++ b/libopenage/presenter/presenter.cpp @@ -93,7 +93,7 @@ std::shared_ptr Presenter::init_window_system() { return std::make_shared(); } -void Presenter::init_graphics(int width, int height, bool debug) { +void Presenter::init_graphics(bool debug, int width, int height) { log::log(INFO << "Presenter: Initializing graphics subsystems..."); // Start up rendering framework diff --git a/openage/game/main.py b/openage/game/main.py index e42fb81a93..854700773e 100644 --- a/openage/game/main.py +++ b/openage/game/main.py @@ -34,7 +34,7 @@ def init_subparser(cli: ArgumentParser) -> None: cli.add_argument( "--check-updates", action='store_true', help="Check if the assets are up to date") - + cli.add_argument( "--width", type=int, default=None, help="width of the game window") @@ -43,7 +43,7 @@ def init_subparser(cli: ArgumentParser) -> None: "--height", type=int, default=None, help="height of the game window" ) - + def main(args, error): """ From af1bbf617c9be70b17f6a75b70fc0c41fdd3530d Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 18:33:00 -0500 Subject: [PATCH 4/8] Changed copyright year from 2023 to 2024 Signed-off-by: Raul Galvez --- libopenage/engine/engine.cpp | 2 +- libopenage/main.cpp | 2 +- libopenage/main.h | 2 +- openage/game/main_cpp.pyx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index bdc1fac61c..eee6fd6959 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -1,4 +1,4 @@ -// Copyright 2023-2023 the openage authors. See copying.md for legal info. +// Copyright 2023-2024 the openage authors. See copying.md for legal info. #include "engine.h" diff --git a/libopenage/main.cpp b/libopenage/main.cpp index 813de85fb6..b642ffe37f 100644 --- a/libopenage/main.cpp +++ b/libopenage/main.cpp @@ -1,4 +1,4 @@ -// Copyright 2015-2023 the openage authors. See copying.md for legal info. +// Copyright 2015-2024 the openage authors. See copying.md for legal info. #include "main.h" diff --git a/libopenage/main.h b/libopenage/main.h index c4d8ff0e00..d0df49b370 100644 --- a/libopenage/main.h +++ b/libopenage/main.h @@ -1,4 +1,4 @@ -// Copyright 2015-2023 the openage authors. See copying.md for legal info. +// Copyright 2015-2024 the openage authors. See copying.md for legal info. #pragma once diff --git a/openage/game/main_cpp.pyx b/openage/game/main_cpp.pyx index 5863ebbcf0..ccd3841575 100644 --- a/openage/game/main_cpp.pyx +++ b/openage/game/main_cpp.pyx @@ -1,4 +1,4 @@ -# Copyright 2015-2023 the openage authors. See copying.md for legal info. +# Copyright 2015-2024 the openage authors. See copying.md for legal info. from cpython.ref cimport PyObject from libcpp.string cimport string From 2e60f896ba8dae65a322dc501521bb287aaef712 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 19:19:45 -0500 Subject: [PATCH 5/8] Update copying.md --- copying.md | 1 + 1 file changed, 1 insertion(+) diff --git a/copying.md b/copying.md index fb6501bab0..2fcdd5d7fa 100644 --- a/copying.md +++ b/copying.md @@ -154,6 +154,7 @@ _the openage authors_ are: | Haoyang Bi | AyiStar | ayistar à outlook dawt com | | Michael Seibt | RoboSchmied | github à roboschmie dawt de | | Nikhil Ghosh | NikhilGhosh75 | nghosh606 à gmail dawt com | +| Raul Galvez | RaulGalvez288 | raul.galvez à outlook dawt com | If you're a first-time committer, add yourself to the above list. This is not just for legal reasons, but also to keep an overview of all those nicknames. From 5e384f8c27fa38e031d05ac47a6354576b410e97 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 19:20:32 -0500 Subject: [PATCH 6/8] Changed 2023 to 2024 in openage/main/main_cpp.pyx --- openage/main/main_cpp.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openage/main/main_cpp.pyx b/openage/main/main_cpp.pyx index 5863ebbcf0..ccd3841575 100644 --- a/openage/main/main_cpp.pyx +++ b/openage/main/main_cpp.pyx @@ -1,4 +1,4 @@ -# Copyright 2015-2023 the openage authors. See copying.md for legal info. +# Copyright 2015-2024 the openage authors. See copying.md for legal info. from cpython.ref cimport PyObject from libcpp.string cimport string From 519b0540d7298f14d731f25583bf6b44398c0bd2 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Tue, 20 Aug 2024 19:27:28 -0500 Subject: [PATCH 7/8] Updated .mailmap --- .mailmap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index fbf10ad63f..c48029e71f 100644 --- a/.mailmap +++ b/.mailmap @@ -20,4 +20,5 @@ Tobias Feldballe Tobias Feldballe Jonas Borchelt Derek Frogget <114030121+derekfrogget@users.noreply.github.com> -Nikhil Ghosh \ No newline at end of file +Nikhil Ghosh +Raul Galvez From 039a2ac710dbffc3269ded75e39dc0ddd6e1c747 Mon Sep 17 00:00:00 2001 From: Raul Galvez Date: Wed, 21 Aug 2024 12:49:20 -0500 Subject: [PATCH 8/8] Made changes according to comments --- libopenage/engine/engine.cpp | 12 ++++++------ openage/game/main.py | 4 ++-- openage/game/main_cpp.pyx | 10 ++-------- openage/main/main.py | 4 ++-- openage/main/main_cpp.pyx | 10 ++-------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/libopenage/engine/engine.cpp b/libopenage/engine/engine.cpp index eee6fd6959..70da6e0216 100644 --- a/libopenage/engine/engine.cpp +++ b/libopenage/engine/engine.cpp @@ -17,13 +17,13 @@ Engine::Engine(mode mode, const util::Path &root_dir, const std::vector &mods, bool debug_graphics, - int wWidth, - int wHeight) : + size_t window_width, + size_t window_height) : running{true}, run_mode{mode}, root_dir{root_dir}, - height{wHeight}, - width{wWidth}, + height{window_height}, + width{window_width}, threads{} { log::log(INFO << "launching engine with root directory" @@ -61,8 +61,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, width, height); + this->threads.emplace_back([&, debug_graphics, window_width, window_height]() { + this->presenter->run(debug_graphics); // Make sure that the presenter gets destructed in the same thread // otherwise OpenGL complains about missing contexts diff --git a/openage/game/main.py b/openage/game/main.py index 854700773e..2688eb3ec1 100644 --- a/openage/game/main.py +++ b/openage/game/main.py @@ -36,11 +36,11 @@ def init_subparser(cli: ArgumentParser) -> None: help="Check if the assets are up to date") cli.add_argument( - "--width", type=int, default=None, + "--width", type=int, default=1024, help="width of the game window") cli.add_argument( - "--height", type=int, default=None, + "--height", type=int, default=768, help="height of the game window" ) diff --git a/openage/game/main_cpp.pyx b/openage/game/main_cpp.pyx index ccd3841575..82c92c4654 100644 --- a/openage/game/main_cpp.pyx +++ b/openage/game/main_cpp.pyx @@ -38,16 +38,10 @@ def run_game(args, root_path): args_cpp.mods = vector[string]() # window width - if args.width is not None: - args_cpp.width = args.width - else: - args_cpp.width = 1024 + args_cpp.width = args.width # window height - if args.height is not None: - args_cpp.height = args.height - else: - args_cpp.height = 768 + args_cpp.height = args.height # run the game! with nogil: diff --git a/openage/main/main.py b/openage/main/main.py index 5bb328a518..161227ab4c 100644 --- a/openage/main/main.py +++ b/openage/main/main.py @@ -29,11 +29,11 @@ def init_subparser(cli: ArgumentParser): help="list of modpacks to load") cli.add_argument( - "--width", type=int, default=None, + "--width", type=int, default=1024, help="width of the game window") cli.add_argument( - "--height", type=int, default=None, + "--height", type=int, default=768, help="height of the game window" ) diff --git a/openage/main/main_cpp.pyx b/openage/main/main_cpp.pyx index ccd3841575..82c92c4654 100644 --- a/openage/main/main_cpp.pyx +++ b/openage/main/main_cpp.pyx @@ -38,16 +38,10 @@ def run_game(args, root_path): args_cpp.mods = vector[string]() # window width - if args.width is not None: - args_cpp.width = args.width - else: - args_cpp.width = 1024 + args_cpp.width = args.width # window height - if args.height is not None: - args_cpp.height = args.height - else: - args_cpp.height = 768 + args_cpp.height = args.height # run the game! with nogil: