Skip to content

Commit

Permalink
Merge pull request #543 from Pedro-Beirao/master
Browse files Browse the repository at this point in the history
* Allow window to be resizable on macOS

* Make sure initial window size is always >= 640x480 (OpenGL)
  • Loading branch information
Pedro-Beirao authored Dec 4, 2024
2 parents 5af4e71 + a74d2da commit 22a5e97
Showing 1 changed file with 22 additions and 32 deletions.
54 changes: 22 additions & 32 deletions prboom2/src/SDL/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,21 +1267,33 @@ void I_UpdateVideoMode(void)
init_flags |= SDL_WINDOW_OPENGL;
}

// [FG] aspect ratio correction for the canonical video modes
if (SCREENHEIGHT == 200 || SCREENHEIGHT == 400)
{
actualheight = 6*SCREENHEIGHT/5;
}
else
{
actualheight = SCREENHEIGHT;
}

if (desired_fullscreen)
{
if (exclusive_fullscreen)
init_flags |= SDL_WINDOW_FULLSCREEN;
else
init_flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
}

// In windowed mode, the window can be resized while the game is
// running. This feature is disabled on OS X, as it adds an ugly
// scroll handle to the corner of the screen.
#ifndef __APPLE__
if (!desired_fullscreen)
else
{
init_flags |= SDL_WINDOW_RESIZABLE;
#endif

// [FG] make sure initial window size is always >= 640x480
while (screen_multiply*SCREENWIDTH < 640 || screen_multiply*actualheight < 480)
{
screen_multiply++;
}
}

if (V_IsOpenGLMode())
{
Expand All @@ -1305,10 +1317,10 @@ void I_UpdateVideoMode(void)
sdl_window = SDL_CreateWindow(
PACKAGE_NAME " " PACKAGE_VERSION,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SCREENWIDTH * screen_multiply, SCREENHEIGHT * screen_multiply,
SCREENWIDTH * screen_multiply, actualheight * screen_multiply,
init_flags);
sdl_glcontext = SDL_GL_CreateContext(sdl_window);
SDL_SetWindowMinimumSize(sdl_window, SCREENWIDTH, SCREENHEIGHT);
SDL_SetWindowMinimumSize(sdl_window, SCREENWIDTH, actualheight);
}
else
{
Expand All @@ -1320,35 +1332,13 @@ void I_UpdateVideoMode(void)
sdl_window = SDL_CreateWindow(
PACKAGE_NAME " " PACKAGE_VERSION,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SCREENWIDTH, SCREENHEIGHT,
SCREENWIDTH * screen_multiply, actualheight * screen_multiply,
init_flags);
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, flags);

// [FG] aspect ratio correction for the canonical video modes
if (SCREENHEIGHT == 200 || SCREENHEIGHT == 400)
{
actualheight = 6*SCREENHEIGHT/5;
}
else
{
actualheight = SCREENHEIGHT;
}

SDL_SetWindowMinimumSize(sdl_window, SCREENWIDTH, actualheight);
SDL_RenderSetLogicalSize(sdl_renderer, SCREENWIDTH, actualheight);

// [FG] make sure initial window size is always >= 640x480
while (screen_multiply*SCREENWIDTH < 640 || screen_multiply*actualheight < 480)
{
screen_multiply++;
}

// [FG] apply screen_multiply to initial window size
if (!desired_fullscreen)
{
SDL_SetWindowSize(sdl_window, screen_multiply*SCREENWIDTH, screen_multiply*actualheight);
}

// [FG] force integer scales
SDL_RenderSetIntegerScale(sdl_renderer, integer_scaling);

Expand Down

0 comments on commit 22a5e97

Please sign in to comment.