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 };
|
uv2 = (Vec2){ xr + wr * !sprite.flip_x, yr + hr * !sprite.flip_y };
|
||||||
uv3 = (Vec2){ xr + wr * !sprite.flip_x, yr + hr * sprite.flip_y };
|
uv3 = (Vec2){ xr + wr * !sprite.flip_x, yr + hr * sprite.flip_y };
|
||||||
} else {
|
} else {
|
||||||
const float offx = (sprite.texture_region_opt.x / srcrect.w) * (srcrect.w / dims.w);
|
/* TODO: support for flipping */
|
||||||
const float offy = (sprite.texture_region_opt.y / srcrect.h) * (srcrect.h / dims.h);
|
uv0 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x) / dims.w,
|
||||||
const float offw = (1.0f - (sprite.texture_region_opt.w / srcrect.w)) * (srcrect.w / dims.w);
|
(srcrect.y + sprite.texture_region_opt.y) / dims.h };
|
||||||
const float offh = (1.0f - (sprite.texture_region_opt.h / srcrect.h)) * (srcrect.h / 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 };
|
||||||
uv0 = (Vec2){ xr + offx + wr * sprite.flip_x, yr + offy + hr * sprite.flip_y };
|
uv2 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x + sprite.texture_region_opt.w) / dims.w,
|
||||||
uv1 = (Vec2){ xr + offx + wr * sprite.flip_x, yr - offh + hr * !sprite.flip_y };
|
(srcrect.y + sprite.texture_region_opt.y + sprite.texture_region_opt.h) / dims.h };
|
||||||
uv2 = (Vec2){ xr - offw + wr * !sprite.flip_x, yr - offh + hr * !sprite.flip_y };
|
uv3 = (Vec2){ (srcrect.x + sprite.texture_region_opt.x + sprite.texture_region_opt.w) / dims.w,
|
||||||
uv3 = (Vec2){ xr - offw + wr * !sprite.flip_x, yr + offy + hr * sprite.flip_y };
|
(srcrect.y + sprite.texture_region_opt.y) / dims.h };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* try fitting texture into supplied destination rectangle */
|
/* try fitting texture into supplied destination rectangle */
|
||||||
|
Loading…
Reference in New Issue
Block a user