diff semiconginev2/contrib/algorithms/texture_packing.nim @ 1234:841e12f33c47

add: text & font rendering, not tested yet
author sam <sam@basx.dev>
date Sat, 20 Jul 2024 00:03:57 +0700
parents 4e465583ea32
children c15770761865
line wrap: on
line diff
--- a/semiconginev2/contrib/algorithms/texture_packing.nim	Fri Jul 19 21:25:42 2024 +0700
+++ b/semiconginev2/contrib/algorithms/texture_packing.nim	Sat Jul 20 00:03:57 2024 +0700
@@ -72,6 +72,11 @@
   for rect in assignedAreas:
     for y in 0 ..< rect.h:
       for x in 0 ..< rect.w:
-        assert result.atlas[rect.x + x, rect.y + y] == 0, "Atlas texture packing encountered an overlap error"
+        when T is Gray:
+          assert result.atlas[rect.x + x, rect.y + y] == [0'u8], "Atlas texture packing encountered an overlap error"
+        elif T is RGBA:
+          assert result.atlas[rect.x + x, rect.y + y] == [0'u8, 0'u8, 0'u8, 0'u8], "Atlas texture packing encountered an overlap error"
+        else:
+          {.error: "Unsupported type for texture packing".}
         result.atlas[rect.x + x, rect.y + y] = images[rect.i][x, y]
         result.coords[rect.i] = (x: rect.x, y: rect.y)