From 27f7db8b4651afa1fda83f2c46e02ce5dc4f6f35 Mon Sep 17 00:00:00 2001 From: Fingercomp Date: Mon, 26 Aug 2024 19:42:44 +0700 Subject: [PATCH] Pixel-perfect rendering, 2024 take --- .../ocelot/desktop/graphics/Graphics.scala | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/scala/ocelot/desktop/graphics/Graphics.scala b/src/main/scala/ocelot/desktop/graphics/Graphics.scala index 41c7a10..650e244 100644 --- a/src/main/scala/ocelot/desktop/graphics/Graphics.scala +++ b/src/main/scala/ocelot/desktop/graphics/Graphics.scala @@ -133,7 +133,7 @@ class Graphics(private var width: Int, private var height: Int, private var scal currentFramebuffer = 0 foreground = RGBAColorNorm(1, 1, 1, alpha) spriteRect = Rect2D(0, 1f, 1f, -1f) - _rect(0, 0, width / scalingFactor, height / scalingFactor, fixUV = false) + _rect(0, 0, width / scalingFactor, height / scalingFactor) flush(mainTexture = offscreenTexture) } @@ -141,7 +141,7 @@ class Graphics(private var width: Int, private var height: Int, private var scal flush() foreground = RGBAColorNorm(1, 1, 1, alpha) spriteRect = Rect2D(0, 1f, 1f, -1f) - _rect(bounds.x, bounds.y, bounds.w, bounds.h, fixUV = false) + _rect(bounds.x, bounds.y, bounds.w, bounds.h) flush(mainTexture = viewport.textureColor) } @@ -149,7 +149,7 @@ class Graphics(private var width: Int, private var height: Int, private var scal flush() foreground = RGBAColorNorm(1, 1, 1, alpha) spriteRect = Rect2D(0, 1f, 1f, -1f) - _rect(bounds.x, bounds.y, bounds.w, bounds.h, fixUV = false) + _rect(bounds.x, bounds.y, bounds.w, bounds.h) flush(mainTexture = viewport.texture) } @@ -302,7 +302,7 @@ class Graphics(private var width: Int, private var height: Int, private var scal { sprite = name foreground = color - _rect(x, y, width, height, fixUV = true, animation) + _rect(x, y, width, height, animation) } def rect(r: Rect2D, color: Color): Unit = { @@ -324,7 +324,6 @@ class Graphics(private var width: Int, private var height: Int, private var scal } private def _rect(x: Float, y: Float, width: Float, height: Float, - fixUV: Boolean = true, animation: Option[Animation] = None): Unit = { val spriteRect = animation match { case None => this.spriteRect @@ -348,11 +347,9 @@ class Graphics(private var width: Int, private var height: Int, private var scal this.spriteRect.copy(y = this.spriteRect.y + curFrame * size.height, h = size.height) } - val uvTransform = Transform2D.translate(spriteRect.x, spriteRect.y) >> - (if (fixUV) - Transform2D.scale(spriteRect.w - 0.25f / 1024, spriteRect.h - 0.25f / 1024) - else - Transform2D.scale(spriteRect.w, spriteRect.h)) + val uvTransform = + Transform2D.translate(spriteRect.x, spriteRect.y) >> + Transform2D.scale(spriteRect.w, spriteRect.h) val transform = stack.head.transform >>