Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom resolution size added for start modes main and game #1622

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions libopenage/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace openage::engine {
Engine::Engine(mode mode,
const util::Path &root_dir,
const std::vector<std::string> &mods,
bool debug_graphics) :
bool debug_graphics,
int width,
int height) :
running{true},
run_mode{mode},
root_dir{root_dir},
Expand Down Expand Up @@ -56,7 +58,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
Expand Down
4 changes: 3 additions & 1 deletion libopenage/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class Engine {
Engine(mode mode,
const util::Path &root_dir,
const std::vector<std::string> &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;
Expand Down
2 changes: 1 addition & 1 deletion libopenage/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions libopenage/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ struct main_arguments {
bool gl_debug;
bool headless;
std::vector<std::string> mods;
int width;
int height;
};


Expand Down
8 changes: 4 additions & 4 deletions libopenage/presenter/presenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,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();

Expand Down Expand Up @@ -90,11 +90,11 @@ std::shared_ptr<qtgui::GuiApplication> Presenter::init_window_system() {
return std::make_shared<renderer::gui::GuiApplicationWithLogger>();
}

void Presenter::init_graphics(bool debug) {
void Presenter::init_graphics(bool debug, int width, int height) {
log::log(INFO << "Presenter: Initializing graphics subsystems...");

this->gui_app = this->init_window_system();
this->window = renderer::Window::create("openage presenter test", 1024, 768, debug);
this->window = renderer::Window::create("openage presenter test", width, height, debug);
this->renderer = this->window->make_renderer();

// Asset mangement
Expand Down
6 changes: 4 additions & 2 deletions libopenage/presenter/presenter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* @param height Height of the window.
*/
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.
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions openage/game/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ def init_subparser(cli: ArgumentParser) -> None:
cli.add_argument(
"--modpacks", nargs="+", required=True,
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):
Expand Down
11 changes: 11 additions & 0 deletions openage/game/main_cpp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def run_game(args, root_path):
args_cpp.mods = args.modpacks
else:
args_cpp.mods = vector[string]()

# window dimensions
if args.width is not None:
args_cpp.width = args.width
else:
args_cpp.width = 1024

if args.height is not None:
args_cpp.height = args.height
else:
args_cpp.height = 768

# run the game!
with nogil:
Expand Down
8 changes: 8 additions & 0 deletions openage/main/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ def init_subparser(cli: ArgumentParser):
cli.add_argument(
"--modpacks", nargs="+",
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):
Expand Down
11 changes: 11 additions & 0 deletions openage/main/main_cpp.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def run_game(args, root_path):
args_cpp.mods = args.modpacks
else:
args_cpp.mods = vector[string]()

# window dimensions
if args.width is not None:
args_cpp.width = args.width
else:
args_cpp.width = 1024

if args.height is not None:
args_cpp.height = args.height
else:
args_cpp.height = 768

# run the game!
with nogil:
Expand Down