Added tex max check

This commit is contained in:
h4570
2020-12-06 00:13:37 +01:00
parent b8552330bd
commit 67a10cb724
+5 -4
View File
@@ -102,12 +102,13 @@ void Renderer::changeTexture(Texture *t_tex)
void Renderer::draw(Sprite &t_sprite) void Renderer::draw(Sprite &t_sprite)
{ {
texrect_t rect; texrect_t rect;
float texS = 128.0F; float texMax = t_sprite.size.x > t_sprite.size.y ? t_sprite.size.x : t_sprite.size.y;
float texT = 128.0F; float texS = texMax;
float texT = texMax;
if (t_sprite.size.x > t_sprite.size.y) if (t_sprite.size.x > t_sprite.size.y)
texT = 128.0F / (t_sprite.size.x / t_sprite.size.y); texT = texMax / (t_sprite.size.x / t_sprite.size.y);
else if (t_sprite.size.y > t_sprite.size.x) else if (t_sprite.size.y > t_sprite.size.x)
texS = 128.0F / (t_sprite.size.y / t_sprite.size.x); texS = texMax / (t_sprite.size.y / t_sprite.size.x);
rect.t0.s = t_sprite.isFlippedHorizontally() ? texS : 0.0F; rect.t0.s = t_sprite.isFlippedHorizontally() ? texS : 0.0F;
rect.t0.t = t_sprite.isFlippedVertically() ? texT : 0.0F; rect.t0.t = t_sprite.isFlippedVertically() ? texT : 0.0F;
rect.t1.s = t_sprite.isFlippedHorizontally() ? 0.0F : texS; rect.t1.s = t_sprite.isFlippedHorizontally() ? 0.0F : texS;