Skip to content

Commit

Permalink
Make sure initial window size is always >= 640x480 (OpenGL)
Browse files Browse the repository at this point in the history
Only software used to have this behaviour
  • Loading branch information
Pedro-Beirao committed Nov 29, 2024
1 parent b9f0b9b commit a74d2da
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions prboom2/src/SDL/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1267,16 +1267,34 @@ 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;
}

else
{
init_flags |= SDL_WINDOW_RESIZABLE;

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

if (V_IsOpenGLMode())
{
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 0 );
Expand All @@ -1299,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 @@ -1314,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 Expand Up @@ -1550,6 +1546,11 @@ static dboolean MouseShouldBeGrabbed()
if (!window_focused)
return false;

// always grab the mouse when full screen (dont want to
// see the mouse pointer)
if (desired_fullscreen)
return true;

// if we specify not to grab the mouse, never grab
if (!mouse_enabled)
return false;
Expand Down

0 comments on commit a74d2da

Please sign in to comment.