Skip to content

Instantly share code, notes, and snippets.

@The-King-of-Toasters
Last active May 13, 2021 10:50
Show Gist options
  • Save The-King-of-Toasters/404134ff72616e187be6f3f603b1133c to your computer and use it in GitHub Desktop.
Save The-King-of-Toasters/404134ff72616e187be6f3f603b1133c to your computer and use it in GitHub Desktop.
cstdoom3 hud correction
/*
===================
idPlayerView::RenderPlayerView
===================
*/
void idPlayerView::RenderPlayerView( idUserInterface *hud ) {
const renderView_t *view = player->GetRenderView();
SingleView( hud, view );
ScreenFade();
if ( net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient ) {
//#modified-fva; BEGIN
/*
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
renderSystem->DrawStretchPic( 10.0f, 380.0f, 64.0f, 64.0f, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial );
*/
float x = 10.0f;
float y = 380.0f;
float w = 64.0f;
float h = 64.0f;
if (cvarSystem->GetCVarBool("cst_hudAdjustAspect")) {
// similar to CST_ANCHOR_BOTTOM_LEFT
int glWidth, glHeight;
renderSystem->GetGLSettings(glWidth, glHeight);
if (glWidth > 0 && glHeight > 0) {
float glAspectRatio = (float)glWidth / (float)glHeight;
const float vidWidth = SCREEN_WIDTH;
const float vidHeight = SCREEN_HEIGHT;
const float vidAspectRatio = (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT;
float modWidth = vidWidth;
float modHeight = vidHeight;
if (glAspectRatio >= vidAspectRatio) {
modWidth = modHeight * glAspectRatio;
} else {
modHeight = modWidth / glAspectRatio;
}
float xScale = vidWidth / modWidth;
float yScale = vidHeight / modHeight;
float xOffset = 0.0f;
float yOffset = vidHeight * (1.0f - yScale);
x = x * xScale + xOffset;
y = y * yScale + yOffset;
w *= xScale;
h *= yScale;
}
}
renderSystem->SetColor4(1.0f, 1.0f, 1.0f, 1.0f);
renderSystem->DrawStretchPic(x, y, w, h, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial);
//#modified-fva; END
}
}
/*
===================
idPlayerView::RenderPlayerView
===================
*/
void idPlayerView::RenderPlayerView( idUserInterface *hud ) {
const renderView_t *view = player->GetRenderView();
if ( g_skipViewEffects.GetBool() ) {
//#modified-fva; BEGIN
#if CST_ROE_WEAPONS
SingleView(hud, view, false);
#else
SingleView( hud, view );
#endif
//#modified-fva; END
} else {
if ( player->GetInfluenceMaterial() || player->GetInfluenceEntity() ) {
InfluenceVision( hud, view );
} else if ( gameLocal.time < dvFinishTime ) {
DoubleVision( hud, view, dvFinishTime - gameLocal.time );
} else if ( player->PowerUpActive( BERSERK ) ) {
BerserkVision( hud, view );
} else {
//#modified-fva; BEGIN
#if CST_ROE_WEAPONS
SingleView(hud, view, false);
#else
SingleView( hud, view );
#endif
//#modified-fva; END
}
ScreenFade();
}
if ( net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient ) {
//#modified-fva; BEGIN
/*
renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f );
renderSystem->DrawStretchPic( 10.0f, 380.0f, 64.0f, 64.0f, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial );
*/
float x = 10.0f;
float y = 380.0f;
float w = 64.0f;
float h = 64.0f;
if (cvarSystem->GetCVarBool("cst_hudAdjustAspect")) {
// similar to CST_ANCHOR_BOTTOM_LEFT
int glWidth, glHeight;
renderSystem->GetGLSettings(glWidth, glHeight);
if (glWidth > 0 && glHeight > 0) {
float glAspectRatio = (float)glWidth / (float)glHeight;
const float vidWidth = SCREEN_WIDTH;
const float vidHeight = SCREEN_HEIGHT;
const float vidAspectRatio = (float)SCREEN_WIDTH / (float)SCREEN_HEIGHT;
float modWidth = vidWidth;
float modHeight = vidHeight;
if (glAspectRatio >= vidAspectRatio) {
modWidth = modHeight * glAspectRatio;
} else {
modHeight = modWidth / glAspectRatio;
}
float xScale = vidWidth / modWidth;
float yScale = vidHeight / modHeight;
float xOffset = 0.0f;
float yOffset = vidHeight * (1.0f - yScale);
x = x * xScale + xOffset;
y = y * yScale + yOffset;
w *= xScale;
h *= yScale;
}
}
renderSystem->SetColor4(1.0f, 1.0f, 1.0f, 1.0f);
renderSystem->DrawStretchPic(x, y, w, h, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial);
//#modified-fva; END
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment