Skip to content

Commit

Permalink
Merge pull request #563 from Pedro-Beirao/resolutions
Browse files Browse the repository at this point in the history
More window improvements
  • Loading branch information
Pedro-Beirao authored Jan 7, 2025
2 parents 90dd472 + 22896be commit 85746d2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
33 changes: 13 additions & 20 deletions prboom2/src/SDL/i_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,17 +1076,17 @@ void I_InitScreenResolution(void)

desired_fullscreen = dsda_IntConfig(dsda_config_use_fullscreen);

if (dsda_Flag(dsda_arg_fullscreen))
desired_fullscreen = 1;

if (dsda_Flag(dsda_arg_window))
desired_fullscreen = 0;

if (init)
{
//e6y: ability to change screen resolution from GUI
I_FillScreenResolutionsList();

if (dsda_Flag(dsda_arg_fullscreen))
desired_fullscreen = 1;

if (dsda_Flag(dsda_arg_window))
desired_fullscreen = 0;

// Video stuff
arg = dsda_Arg(dsda_arg_width);
if (arg->found)
Expand Down Expand Up @@ -1223,7 +1223,6 @@ void I_UpdateVideoMode(void)
{
int init_flags = SDL_WINDOW_ALLOW_HIGHDPI;
int screen_multiply;
int actualheight;
int render_vsync;
int integer_scaling;
const char *sdl_video_window_pos;
Expand Down Expand Up @@ -1273,11 +1272,11 @@ void I_UpdateVideoMode(void)
// [FG] aspect ratio correction for the canonical video modes
if (SCREENHEIGHT == 200 || SCREENHEIGHT == 400)
{
actualheight = 6*SCREENHEIGHT/5;
ACTUALHEIGHT = 6*SCREENHEIGHT/5;
}
else
{
actualheight = SCREENHEIGHT;
ACTUALHEIGHT = SCREENHEIGHT;
}

if (desired_fullscreen)
Expand All @@ -1290,12 +1289,6 @@ void I_UpdateVideoMode(void)
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())
Expand All @@ -1320,10 +1313,10 @@ void I_UpdateVideoMode(void)
sdl_window = SDL_CreateWindow(
PACKAGE_NAME " " PACKAGE_VERSION,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SCREENWIDTH * screen_multiply, actualheight * screen_multiply,
SCREENWIDTH * screen_multiply, ACTUALHEIGHT * screen_multiply,
init_flags);
sdl_glcontext = SDL_GL_CreateContext(sdl_window);
SDL_SetWindowMinimumSize(sdl_window, SCREENWIDTH, actualheight);
SDL_SetWindowMinimumSize(sdl_window, SCREENWIDTH, ACTUALHEIGHT);
}
else
{
Expand All @@ -1335,12 +1328,12 @@ void I_UpdateVideoMode(void)
sdl_window = SDL_CreateWindow(
PACKAGE_NAME " " PACKAGE_VERSION,
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SCREENWIDTH * screen_multiply, actualheight * screen_multiply,
SCREENWIDTH * screen_multiply, ACTUALHEIGHT * screen_multiply,
init_flags);
sdl_renderer = SDL_CreateRenderer(sdl_window, -1, flags);

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

// [FG] force integer scales
SDL_RenderSetIntegerScale(sdl_renderer, integer_scaling);
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/doomdef.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
// proff 08/17/98: Changed for high-res
int SCREENWIDTH=320;
int SCREENHEIGHT=200;
int ACTUALHEIGHT=240;
int SCREENPITCH=320;

// e6y: wide-res
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/doomdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ typedef enum {
// SCREENWIDTH and SCREENHEIGHT define the visible size
extern int SCREENWIDTH;
extern int SCREENHEIGHT;
// ACTUALHEIGHT is the actual height of the resolution
// If the resolution is 200p or 400p, aspect ratio correction
// should be applied, making this value 240 or 480
extern int ACTUALHEIGHT;
// SCREENPITCH is the size of one line in the buffer and
// can be bigger than the SCREENWIDTH depending on the size
// of one pixel (8, 16 or 32 bit) and the padding at the
Expand Down
4 changes: 2 additions & 2 deletions prboom2/src/dsda/gl/render_scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void dsda_GLGetSDLWindowSize(SDL_Window* sdl_window) {
void dsda_GLSetRenderViewportParams() {
float viewport_aspect;

viewport_aspect = (float)SCREENWIDTH / (float)SCREENHEIGHT;
viewport_aspect = (float)SCREENWIDTH / (float)ACTUALHEIGHT;

// Black bars on left and right of viewport
if ((int)(gl_window_height * viewport_aspect) < gl_window_width) {
Expand All @@ -66,7 +66,7 @@ void dsda_GLSetRenderViewportParams() {
}

gl_scale_x = (float)gl_viewport_width / (float)SCREENWIDTH;
gl_scale_y = (float)gl_viewport_height / (float)SCREENHEIGHT;
gl_scale_y = (float)gl_viewport_height / (float)ACTUALHEIGHT;

// elim - This will be zero if no statusbar is being drawn
gl_statusbar_height = (int)(gl_scale_y * (float)ST_SCALED_HEIGHT) * R_PartialView();
Expand Down

0 comments on commit 85746d2

Please sign in to comment.