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

Add new command line option: -display #657

Merged
merged 2 commits into from
Dec 20, 2024
Merged
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
1 change: 1 addition & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Here brief usage of command line options, supported by game.
| Option | Type | Default | Platform | Description |
|----------------------|---------|-------------------------------------|----------|-------------------------------------------------------------------|
| `-dedicated`, `-d` | boolean | Off | all | Run game in dedicated mode |
| `-display` | integer | 0 | all | Run game on the selected display |
| `-fullscreen`, `-f` | boolean | On | all | Run game in fullscreen mode |
| `-logfile` | boolean | Off | all | Enable file logging to Descent3.log |
| `-loglevel <LEVEL>` | string | INFO (on Release), DEBUG (on Debug) | all | Set log level (NONE, VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL) |
Expand Down
16 changes: 15 additions & 1 deletion renderer/HardwareOpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,21 @@ int opengl_Setup(oeApplication *app, const int *width, const int *height) {
}

if (!GSDLWindow) {
GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, winw, winh, flags);
int display = 0;
if (int display_arg = FindArg("-display"); display_arg != 0) {
if (const char * arg_index_str = GetArg (display_arg + 1); arg_index_str == nullptr) {
LOG_WARNING << "No parameter for -display given";
} else {
int arg_index = atoi(arg_index_str);
int display_count = SDL_GetNumVideoDisplays();
if ((arg_index < 0) || (arg_index >= display_count)) {
LOG_WARNING.printf( "Parameter for -display must be in the range 0..%i", display_count-1 );
} else {
display = arg_index;
}
}
}
GSDLWindow = SDL_CreateWindow("Descent 3", SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), SDL_WINDOWPOS_UNDEFINED_DISPLAY(display), winw, winh, flags);
if (!GSDLWindow) {
LOG_ERROR.printf("OpenGL: SDL window creation failed: %s", SDL_GetError());
return 0;
Expand Down
Loading