Skip to content

Commit

Permalink
Add support for multiple screens (#876)
Browse files Browse the repository at this point in the history
In the config file, in the general section, add a line with "screen" and a value of 1.
<section name="general">
        <var name="screen" value="1" />
Fixes #863.
  • Loading branch information
royfalk authored Sep 25, 2024
1 parent cbcae9d commit 307d2c4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions engine/src/configuration/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Configuration::Configuration() {
* behavior/range bounding is complicated/necessary-for-stability abd additional validation code is required for checking/adjusting user inputs
*/
void Configuration::OverrideDefaultsWithUserConfiguration() {
general_config.screen = GetGameConfig().GetInt16("general.screen", general_config.screen);

general_config.pitch = GetGameConfig().GetFloat("general.pitch", general_config.pitch);
general_config.yaw = GetGameConfig().GetFloat("general.yaw", general_config.yaw);
general_config.roll = GetGameConfig().GetFloat("general.roll", general_config.roll);
Expand Down
3 changes: 3 additions & 0 deletions engine/src/configuration/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ namespace vega_config {
struct GeneralConfig {
GeneralConfig() = default;

int screen{0}; // TODO: move to a dedicated section along with other such paramters.
// e.g. screen width and height, resolution, color, etc.

float pitch{0.0F};
float yaw{0.0F};
float roll{0.0F};
Expand Down
14 changes: 12 additions & 2 deletions engine/src/gldrv/winsys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "vs_logging.h"
#include "options.h"
#include "vs_exit.h"
#include "configuration/configuration.h"

#include "SDL2/SDL_video.h"

Expand Down Expand Up @@ -253,8 +254,17 @@ static bool setup_sdl_video_mode(int *argc, char **argv) {
width = g_game.x_resolution;
height = g_game.y_resolution;


SDL_Window *window = SDL_CreateWindow("Vegastrike", 0, 0, width, height, video_flags);
const int screen_number = configuration()->general_config.screen;
SDL_Window *window = nullptr;
if(screen_number == 0) {
window = SDL_CreateWindow("Vegastrike", 0, 0, width, height, video_flags);
} else {
window = SDL_CreateWindow("Vegastrike",
SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen_number),
SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen_number),
0, 0, video_flags);
}


if(!window) {
std::cerr << "No window\n" << std::flush;
Expand Down

0 comments on commit 307d2c4

Please sign in to comment.