Skip to content

Commit

Permalink
Render V_DrawRawScreen with correct stretch aspect
Browse files Browse the repository at this point in the history
- Note that stbar in "Not Adjusted" aspect currently uses settings for "Doom Format"
  • Loading branch information
andrikpowell committed Dec 1, 2024
1 parent d965029 commit 8b951bf
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 8 deletions.
20 changes: 17 additions & 3 deletions prboom2/src/dsda/stretch.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,15 @@ static void InitStretchParam(stretch_param_t* offsets, int stretch, enum patch_t
break;
}

// Raven HUD breaks in "patch_stretch_not_adjusted",
// so let's use "patch_stretch_doom_format" settings
if (raven && stretch == 0)
{
offsets->video = &video_stretch;
offsets->deltax1 = (SCREENWIDTH - WIDE_SCREENWIDTH) / 2;
offsets->deltax2 = (SCREENWIDTH - WIDE_SCREENWIDTH) / 2;
}

if (flags == VPT_ALIGN_LEFT || flags == VPT_ALIGN_LEFT_BOTTOM || flags == VPT_ALIGN_LEFT_TOP) {
offsets->deltax1 = 0;
offsets->deltax2 = 0;
Expand Down Expand Up @@ -271,9 +280,6 @@ void dsda_EvaluatePatchScale(void) {
SCREENHEIGHT < 200 || WIDE_SCREENHEIGHT < 200)
render_stretch_hud = patch_stretch_fit_to_width;

if (raven && render_stretch_hud == 0)
render_stretch_hud++;

switch (render_stretch_hud) {
case patch_stretch_not_adjusted:
wide_offset2x = SCREENWIDTH - patches_scalex * 320;
Expand All @@ -293,6 +299,14 @@ void dsda_EvaluatePatchScale(void) {
break;
}

// Raven HUD breaks in "patch_stretch_not_adjusted",
// so let's use "patch_stretch_doom_format" settings
if (raven && render_stretch_hud == 0) {
ST_SCALED_HEIGHT = g_st_height * WIDE_SCREENHEIGHT / 200;
wide_offset2x = SCREENWIDTH - WIDE_SCREENWIDTH;
wide_offset2y = SCREENHEIGHT - WIDE_SCREENHEIGHT;
}

wide_offsetx = wide_offset2x / 2;
wide_offsety = wide_offset2y / 2;
}
5 changes: 5 additions & 0 deletions prboom2/src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,11 @@ void ST_SetScaledWidth(void)
break;
}

// Raven HUD breaks in "patch_stretch_not_adjusted",
// so let's use "patch_stretch_doom_format" settings
if (raven && render_stretch_hud == 0)
ST_SCALED_WIDTH = width * WIDE_SCREENWIDTH / 320;

ST_SCALED_WIDTH = (ST_SCALED_WIDTH + 3) & (int)~3;

if (ST_SCALED_WIDTH > SCREENWIDTH)
Expand Down
28 changes: 23 additions & 5 deletions prboom2/src/v_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1440,11 +1440,29 @@ void V_DrawRawScreenSection(const char *lump_name, int source_offset, int dest_y
}
}

x_factor = (float)SCREENWIDTH / 320;
y_factor = (float)SCREENHEIGHT / 200;

if (y_factor < x_factor)
x_factor = y_factor;
switch (render_stretch_hud) {
case patch_stretch_not_adjusted:
x_factor = (float)SCREENWIDTH / 320;
y_factor = (float)SCREENHEIGHT / 200;
if (y_factor < x_factor)
x_factor = y_factor;
break;
case patch_stretch_doom_format:
x_factor = (float)WIDE_SCREENWIDTH / 320;
y_factor = (float)WIDE_SCREENHEIGHT / 200;
if (y_factor < x_factor)
x_factor = y_factor;
break;
case patch_stretch_fit_to_width:
x_factor = (float)SCREENWIDTH / 320;
y_factor = (float)SCREENHEIGHT / 200;
break;
default:
// This should never happen
x_factor = 0;
y_factor = 0;
break;
}

x_offset = (int)((SCREENWIDTH - (x_factor * 320)) / 2);
y_offset = (int)((dest_y_offset * y_factor) - (source_offset * y_factor / 320));
Expand Down

0 comments on commit 8b951bf

Please sign in to comment.