allow optionally setting the window size
This commit is contained in:
parent
2770b3c524
commit
8ad0f536d6
4 changed files with 28 additions and 4 deletions
src
|
@ -213,7 +213,7 @@ struct EventCallback {
|
|||
class CVideo
|
||||
{
|
||||
public:
|
||||
CVideo() : Width(0), Height(0), Depth(0), ShaderIndex(0), FullScreen(false) {}
|
||||
CVideo() : Width(0), Height(0), WindowWidth(0), WindowHeight(0), Depth(0), FullScreen(false) {}
|
||||
|
||||
void LockScreen();
|
||||
void UnlockScreen();
|
||||
|
@ -286,9 +286,10 @@ public:
|
|||
|
||||
int Width;
|
||||
int Height;
|
||||
int WindowWidth;
|
||||
int WindowHeight;
|
||||
SDL_Cursor *blankCursor;
|
||||
int Depth;
|
||||
int ShaderIndex;
|
||||
bool FullScreen;
|
||||
};
|
||||
|
||||
|
|
|
@ -578,6 +578,25 @@ void ParseCommandLine(int argc, char **argv, Parameters ¶meters)
|
|||
continue;
|
||||
}
|
||||
case 'W':
|
||||
if (optind < argc && argv[optind] && argv[optind][0] != '-') {
|
||||
// allow -W to take an optional argument in a POSIX compliant way
|
||||
optarg = argv[optind];
|
||||
sep = strchr(optarg, 'x');
|
||||
if (!sep || !*(sep + 1)) {
|
||||
fprintf(stderr, "%s: incorrect window size -- '%s'\n", argv[0], optarg);
|
||||
Usage();
|
||||
exit(-1);
|
||||
}
|
||||
Video.WindowHeight = atoi(sep + 1);
|
||||
*sep = 0;
|
||||
Video.WindowWidth = atoi(optarg);
|
||||
if (!Video.WindowHeight || !Video.WindowWidth) {
|
||||
fprintf(stderr, "%s: incorrect window size -- '%sx%s'\n", argv[0], optarg, sep + 1);
|
||||
Usage();
|
||||
exit(-1);
|
||||
}
|
||||
optind += 1; // skip the optional window size argument
|
||||
}
|
||||
VideoForceFullScreen = 1;
|
||||
Video.FullScreen = 0;
|
||||
continue;
|
||||
|
|
|
@ -12,7 +12,6 @@ public:
|
|||
int Width;
|
||||
int Height;
|
||||
int Depth;
|
||||
int ShaderIndex;
|
||||
bool FullScreen;
|
||||
bool ResizeScreen(int width, int height);
|
||||
};
|
||||
|
|
|
@ -319,6 +319,11 @@ void InitVideoSdl()
|
|||
Video.Height = 480;
|
||||
}
|
||||
|
||||
if (!Video.WindowWidth || !Video.WindowHeight) {
|
||||
Video.WindowWidth = Video.Width;
|
||||
Video.WindowHeight = Video.Height;
|
||||
}
|
||||
|
||||
if (!Video.Depth) {
|
||||
Video.Depth = 32;
|
||||
}
|
||||
|
@ -332,7 +337,7 @@ void InitVideoSdl()
|
|||
}
|
||||
|
||||
TheWindow = SDL_CreateWindow(win_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
Video.Width, Video.Height, flags);
|
||||
Video.WindowWidth, Video.WindowHeight, flags);
|
||||
if (TheWindow == NULL) {
|
||||
fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
|
||||
Video.Width, Video.Height, Video.Depth, SDL_GetError());
|
||||
|
|
Loading…
Add table
Reference in a new issue