Skip to content

Commit

Permalink
Fixed problem in ST_drawHUDSprite which assumed psprite textures were…
Browse files Browse the repository at this point in the history
… always resized to a power of two. Which may not be the case now that we can take advantage of this.
  • Loading branch information
danij committed Dec 29, 2008
1 parent f8bb0a6 commit 6a3a4a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
28 changes: 9 additions & 19 deletions doomsday/plugins/jdoom/src/st_stuff.c
Expand Up @@ -999,8 +999,7 @@ void ST_HUDSpriteSize(int sprite, int *w, int *h)
void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,
float scale, float alpha, boolean flip)
{
int w, h, w2, h2;
float s, t;
int w, h;
spriteinfo_t sprInfo;

if(!(alpha > 0))
Expand All @@ -1010,8 +1009,6 @@ void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,
R_GetSpriteInfo(sprite, 0, &sprInfo);
w = sprInfo.width;
h = sprInfo.height;
w2 = M_CeilPow2(w);
h2 = M_CeilPow2(h);

switch(hotspot)
{
Expand All @@ -1029,26 +1026,19 @@ void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,

GL_SetPSprite(sprInfo.materialNum);

// Let's calculate texture coordinates.
// To remove a possible edge artifact, move the corner a bit up/left.
s = (w - 0.4f) / w2;
t = (h - 0.4f) / h2;

DGL_Color4f(1, 1, 1, alpha);
DGL_Begin(DGL_QUADS);
DGL_TexCoord2f(flip * 0, 0);
DGL_Vertex2f(x, y);

DGL_TexCoord2f(flip * s, 0);
DGL_Vertex2f(x, y);

DGL_TexCoord2f(!flip * s, 0);
DGL_Vertex2f(x + w * scale, y);

DGL_TexCoord2f(!flip * s, t);
DGL_Vertex2f(x + w * scale, y + h * scale);
DGL_TexCoord2f(!flip * 1, 0);
DGL_Vertex2f(x + w * scale, y);

DGL_TexCoord2f(flip * s, t);
DGL_Vertex2f(x, y + h * scale);
DGL_TexCoord2f(!flip * 1, 1);
DGL_Vertex2f(x + w * scale, y + h * scale);

DGL_TexCoord2f(flip * 0, 1);
DGL_Vertex2f(x, y + h * scale);
DGL_End();
}

Expand Down
29 changes: 10 additions & 19 deletions doomsday/plugins/jdoom64/src/st_stuff.c
Expand Up @@ -314,8 +314,8 @@ void ST_HUDSpriteSize(int sprite, int *w, int *h)
void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,
float scale, float a, boolean flip)
{
int w, h, w2, h2;
float s, t, alpha;
int w, h;
float alpha;
spriteinfo_t sprInfo;

if(!(a > 0.f))
Expand All @@ -325,8 +325,6 @@ void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,
R_GetSpriteInfo(sprite, 0, &sprInfo);
w = sprInfo.width;
h = sprInfo.height;
w2 = M_CeilPow2(w);
h2 = M_CeilPow2(h);

switch(hotspot)
{
Expand All @@ -345,26 +343,19 @@ void ST_drawHUDSprite(int sprite, float x, float y, hotloc_t hotspot,

GL_SetPSprite(sprInfo.materialNum);

// Let's calculate texture coordinates.
// To remove a possible edge artifact, move the corner a bit up/left.
s = (w - 0.4f) / w2;
t = (h - 0.4f) / h2;

DGL_Color4f(1, 1, 1, alpha);
DGL_Begin(DGL_QUADS);
DGL_TexCoord2f(flip * 0, 0);
DGL_Vertex2f(x, y);

DGL_TexCoord2f(flip * s, 0);
DGL_Vertex2f(x, y);

DGL_TexCoord2f(!flip * s, 0);
DGL_Vertex2f(x + w * scale, y);

DGL_TexCoord2f(!flip * s, t);
DGL_Vertex2f(x + w * scale, y + h * scale);
DGL_TexCoord2f(!flip * 1, 0);
DGL_Vertex2f(x + w * scale, y);

DGL_TexCoord2f(flip * s, t);
DGL_Vertex2f(x, y + h * scale);
DGL_TexCoord2f(!flip * 1, 1);
DGL_Vertex2f(x + w * scale, y + h * scale);

DGL_TexCoord2f(flip * 0, 1);
DGL_Vertex2f(x, y + h * scale);
DGL_End();
}

Expand Down

0 comments on commit 6a3a4a4

Please sign in to comment.