Skip to content

Commit

Permalink
preload damagescreen texture to reduce stutter
Browse files Browse the repository at this point in the history
  • Loading branch information
no-lex committed Oct 11, 2023
1 parent 06501db commit 2c8baac
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/engine/render/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,17 @@ namespace

void drawdamagescreen(int w, int h)
{
if(lastmillis >= damageblendmillis)
{
return;
}
hudshader->set();
static Texture *damagetex = nullptr;
//preload this texture even if not going to draw, to prevent stutter when first hit
if(!damagetex)
{
damagetex = textureload("media/interface/hud/damage.png", 3);
}
if(lastmillis >= damageblendmillis)
{
return;
}
hudshader->set();
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, damagetex->id);
float fade = damagescreenalpha/100.0f;
Expand Down

0 comments on commit 2c8baac

Please sign in to comment.