align to pixel grid when rendering

This commit is contained in:
Crispy 2024-12-05 12:05:28 +01:00
parent b986ce77a7
commit 89f92a0412

View file

@ -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()
}