Skip to content

Commit 4ff0665

Browse files
authored
Merge pull request #657 from sebholt/display
Add new command line option: -display
2 parents 72f51b0 + bc12e2b commit 4ff0665

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

USAGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Here brief usage of command line options, supported by game.
8787
| Option | Type | Default | Platform | Description |
8888
|----------------------|---------|-------------------------------------|----------|-------------------------------------------------------------------|
8989
| `-dedicated`, `-d` | boolean | Off | all | Run game in dedicated mode |
90+
| `-display` | integer | 0 | all | Run game on the selected display |
9091
| `-fullscreen`, `-f` | boolean | On | all | Run game in fullscreen mode |
9192
| `-logfile` | boolean | Off | all | Enable file logging to Descent3.log |
9293
| `-loglevel <LEVEL>` | string | INFO (on Release), DEBUG (on Debug) | all | Set log level (NONE, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL) |

renderer/HardwareOpenGL.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,21 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) {
424424
}
425425

426426
if (!GSDLWindow) {
427-
GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winw, winh, flags);
427+
int display = 0;
428+
if (int display_arg = FindArg("-display"); display_arg != 0) {
429+
if (const char * arg_index_str = GetArg (display_arg + 1); arg_index_str == nullptr) {
430+
LOG_WARNING << "No parameter for -display given";
431+
} else {
432+
int arg_index = atoi(arg_index_str);
433+
int display_count = SDL_GetNumVideoDisplays();
434+
if ((arg_index < 0) || (arg_index >= display_count)) {
435+
LOG_WARNING.printf( "Parameter for -display must be in the range 0..%i", display_count-1 );
436+
} else {
437+
display = arg_index;
438+
}
439+
}
440+
}
441+
GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), winw, winh, flags);
428442
if (!GSDLWindow) {
429443
LOG_ERROR.printf("OpenGL: SDL window creation failed: %s", SDL_GetError());
430444
return 0;

0 commit comments

Comments
 (0)