fixed broken scaling in sprite rendering

pull/5/head
Sara 2023-05-14 14:46:12 +02:00
parent 2e7b3d3c4a
commit 04101f6427
1 changed files with 2 additions and 12 deletions

View File

@ -79,18 +79,8 @@ SDL_FRect get_dest_with_size(SDL_FRect untransformed, int ui) {
static
void _exec_sprite_cmd(const drawcmd_t* cmd) {
const sprite_t* sprite = &cmd->sprite;
float fw, fh, fwm, fhm;
get_scaling_factors(&fw, &fh, &fwm, &fhm, 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_FRect untransformed = {sprite->x, sprite->y, sprite->sx, sprite->sy};
SDL_FRect destrect = get_dest_with_size(untransformed, cmd->ui);
SDL_RenderCopyExF(g_context.renderer, sprite->texture,
&sprite->uv, &destrect, sprite->rot,
&sprite->origin,SDL_FLIP_NONE);