From 89f92a04123604f30d69c8992e461e5012377a32 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 5 Dec 2024 12:05:28 +0100 Subject: [PATCH] align to pixel grid when rendering --- showimage.odin | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/showimage.odin b/showimage.odin index 16d3f61..373dad4 100644 --- a/showimage.odin +++ b/showimage.odin @@ -2,6 +2,7 @@ package showimage import "core:os" import "core:fmt" +import "core:math" import "core:strings" import rl "vendor:raylib" @@ -51,7 +52,10 @@ main :: proc() { rl.BeginDrawing() rl.ClearBackground({50, 50, 50, 255}) if tex != nil { - rl.DrawTextureEx(tex^, offset, 0, zoom, rl.WHITE) + factor := max(1, zoom) + scaled := offset / factor + aligned_offset : [2]f32 = {math.floor(scaled.x), math.floor(scaled.y)} * factor + rl.DrawTextureEx(tex^, aligned_offset, 0, zoom, rl.WHITE) } rl.EndDrawing() }