fixed broken scaling in sprite rendering
parent
2e7b3d3c4a
commit
04101f6427
|
@ -79,18 +79,8 @@ SDL_FRect get_dest_with_size(SDL_FRect untransformed, int ui) {
|
||||||
static
|
static
|
||||||
void _exec_sprite_cmd(const drawcmd_t* cmd) {
|
void _exec_sprite_cmd(const drawcmd_t* cmd) {
|
||||||
const sprite_t* sprite = &cmd->sprite;
|
const sprite_t* sprite = &cmd->sprite;
|
||||||
float fw, fh, fwm, fhm;
|
SDL_FRect untransformed = {sprite->x, sprite->y, sprite->sx, sprite->sy};
|
||||||
get_scaling_factors(&fw, &fh, &fwm, &fhm, cmd->ui);
|
SDL_FRect destrect = get_dest_with_size(untransformed, cmd->ui);
|
||||||
SDL_FRect destrect = (SDL_FRect){
|
|
||||||
.x=((-g_active_view.x)+(fw*0.5f)+sprite->x)*fwm,
|
|
||||||
.y=((-g_active_view.y)+(fh*0.5f)+sprite->y)*fwm,
|
|
||||||
.w=sprite->sx*fwm,
|
|
||||||
.h=sprite->sy*fwm
|
|
||||||
};
|
|
||||||
if(cmd->ui) {
|
|
||||||
destrect.x = cmd->sprite.x * fwm;
|
|
||||||
destrect.y = cmd->sprite.y * fhm;
|
|
||||||
}
|
|
||||||
SDL_RenderCopyExF(g_context.renderer, sprite->texture,
|
SDL_RenderCopyExF(g_context.renderer, sprite->texture,
|
||||||
&sprite->uv, &destrect, sprite->rot,
|
&sprite->uv, &destrect, sprite->rot,
|
||||||
&sprite->origin,SDL_FLIP_NONE);
|
&sprite->origin,SDL_FLIP_NONE);
|
||||||
|
|
Loading…
Reference in New Issue