Skip to content

Commit

Permalink
Support scaling sprites too.
Browse files Browse the repository at this point in the history
  • Loading branch information
skullernet committed Nov 23, 2024
1 parent 18b7a54 commit 0f4f368
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/refresh/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ static void GL_DrawSpriteModel(const model_t *model)
const mspriteframe_t *frame = &model->spriteframes[e->frame % model->numframes];
const image_t *image = frame->image;
const float alpha = (e->flags & RF_TRANSLUCENT) ? e->alpha : 1.0f;
const float scale = e->scale ? e->scale : 1.0f;
glStateBits_t bits = GLS_DEPTHMASK_FALSE | glr.fog_bits;
vec3_t up, down, left, right;

Expand All @@ -353,10 +354,10 @@ static void GL_DrawSpriteModel(const model_t *model)
GL_ArrayBits(GLA_VERTEX | GLA_TC);
GL_Color(1, 1, 1, alpha);

VectorScale(glr.viewaxis[1], frame->origin_x, left);
VectorScale(glr.viewaxis[1], frame->origin_x - frame->width, right);
VectorScale(glr.viewaxis[2], -frame->origin_y, down);
VectorScale(glr.viewaxis[2], frame->height - frame->origin_y, up);
VectorScale(glr.viewaxis[1], frame->origin_x * scale, left);
VectorScale(glr.viewaxis[1], (frame->origin_x - frame->width) * scale, right);
VectorScale(glr.viewaxis[2], -frame->origin_y * scale, down);
VectorScale(glr.viewaxis[2], (frame->height - frame->origin_y) * scale, up);

VectorAdd3(e->origin, down, left, tess.vertices);
VectorAdd3(e->origin, up, left, tess.vertices + 5);
Expand Down

0 comments on commit 0f4f368

Please sign in to comment.