Skip to content

Commit

Permalink
Merge pull request scp-fs2open#5906 from Goober5000/fix_vr_aspect_lock
Browse files Browse the repository at this point in the history
additional HUD fixes for VR
  • Loading branch information
Goober5000 committed Dec 31, 2023
2 parents 202686d + 43f7921 commit 661dceb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
13 changes: 5 additions & 8 deletions code/hud/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,7 @@ void hud_render_preprocess(float frametime)

if ( hud_disabled() ) {
// if the hud is disabled, we still need to make sure that the indicators are properly handled
hud_do_lock_indicators(flFrametime);
hud_do_lock_indicators(frametime);
return;
}

Expand Down Expand Up @@ -1823,15 +1823,15 @@ void hud_maybe_display_supernova()
/**
* @brief Undertakes main HUD render.
*/
void hud_render_all()
void hud_render_all(float frametime)
{
int i;

hud_render_gauges();
hud_render_gauges(-1, frametime);

// start rendering cockpit dependent gauges if possible
for ( i = 0; i < (int)Player_displays.size(); ++i ) {
hud_render_gauges(i);
hud_render_gauges(i, frametime);
}

hud_clear_msg_buffer();
Expand All @@ -1840,7 +1840,7 @@ void hud_render_all()
font::set_font(font::FONT1);
}

void hud_render_gauges(int cockpit_display_num)
void hud_render_gauges(int cockpit_display_num, float frametime)
{
size_t j, num_gauges;
ship_info* sip = &Ship_info[Player_ship->ship_info_index];
Expand All @@ -1866,9 +1866,6 @@ void hud_render_gauges(int cockpit_display_num)
}
}

//Since we render things twice in VR mode, frametime needs to be halved for HUD, as the HUD uses the frametime to advance ANI's and crucially, the missile lock...
float frametime = openxr_enabled() ? flFrametime * 0.5f : flFrametime;

// Check if this ship has its own HUD gauges.
if ( sip->hud_enabled ) {
num_gauges = sip->hud_gauges.size();
Expand Down
4 changes: 2 additions & 2 deletions code/hud/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ void hud_close();
void hud_level_close();
void hud_update_frame(float frametime); // updates hud systems not dependant on rendering
void hud_render_preprocess(float frametime); // renders 3d dependant gauges
void hud_render_all();
void hud_render_gauges(int cockpit_display_num = -1);
void hud_render_all(float frametime);
void hud_render_gauges(int cockpit_display_num, float frametime);
void hud_stop_looped_engine_sounds();

// set the offset values for this render frame
Expand Down
7 changes: 5 additions & 2 deletions freespace2/freespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3841,20 +3841,23 @@ void game_render_hud(camid cid, const fov_t* fov_override = nullptr)
{
gr_reset_clip();

//Since we render things twice in VR mode, frametime needs to be halved for HUD, as the HUD uses the frametime to advance ANI's and crucially, the missile lock...
float frametime = openxr_enabled() ? flFrametime * 0.5f : flFrametime;

if(cid.isValid()) {
g3_start_frame(0); // 0 = turn zbuffering off
g3_set_view( cid.getCamera() );

if (fov_override)
g3_set_fov(*fov_override);

hud_render_preprocess(flFrametime);
hud_render_preprocess(frametime);

g3_end_frame();
}

// main HUD rendering function
hud_render_all();
hud_render_all(frametime);

// Diminish the palette effect
game_flash_diminish(flFrametime);
Expand Down

0 comments on commit 661dceb

Please sign in to comment.