twn_sprites.c: fix texture region
This commit is contained in:
parent
0dc3cf4160
commit
452ecd72fe
@ -133,15 +133,15 @@ void render_sprites(const Primitive2D primitives[],
|
||||
uv2 = (Vec2){ xr + wr * !sprite.flip_x, yr + hr * !sprite.flip_y };
|
||||
uv3 = (Vec2){ xr + wr * !sprite.flip_x, yr + hr * sprite.flip_y };
|
||||
} else {
|
||||
const float offx = (sprite.texture_region_opt.x / srcrect.w) * (srcrect.w / dims.w);
|
||||
const float offy = (sprite.texture_region_opt.y / srcrect.h) * (srcrect.h / dims.h);
|
||||
const float offw = (1.0f - (sprite.texture_region_opt.w / srcrect.w)) * (srcrect.w / dims.w);
|
||||
const float offh = (1.0f - (sprite.texture_region_opt.h / srcrect.h)) * (srcrect.h / dims.h);
|
||||
|
||||
uv0 = (Vec2){ xr + offx + wr * sprite.flip_x, yr + offy + hr * sprite.flip_y };
|
||||
uv1 = (Vec2){ xr + offx + wr * sprite.flip_x, yr - offh + hr * !sprite.flip_y };
|
||||
uv2 = (Vec2){ xr - offw + wr * !sprite.flip_x, yr - offh + hr * !sprite.flip_y };
|
||||
uv3 = (Vec2){ xr - offw + wr * !sprite.flip_x, yr + offy + hr * sprite.flip_y };
|
||||
/* TODO: support for flipping */
|
||||
uv0 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x) / dims.w,
|
||||
(srcrect.y + sprite.texture_region_opt.y) / dims.h };
|
||||
uv1 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x) / dims.w,
|
||||
(srcrect.y + sprite.texture_region_opt.y + sprite.texture_region_opt.h) / dims.h };
|
||||
uv2 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x + sprite.texture_region_opt.w) / dims.w,
|
||||
(srcrect.y + sprite.texture_region_opt.y + sprite.texture_region_opt.h) / dims.h };
|
||||
uv3 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x + sprite.texture_region_opt.w) / dims.w,
|
||||
(srcrect.y + sprite.texture_region_opt.y) / dims.h };
|
||||
}
|
||||
} else {
|
||||
/* try fitting texture into supplied destination rectangle */
|
||||
|
Loading…
Reference in New Issue
Block a user