diff tests/test_materials.nim @ 420:91e018270832

fix: all tests (once more)
author Sam <sam@basx.dev>
date Mon, 29 Jan 2024 00:19:35 +0700
parents ffc265916415
children 6406766a222d
line wrap: on
line diff
--- a/tests/test_materials.nim	Sun Jan 28 22:18:25 2024 +0700
+++ b/tests/test_materials.nim	Mon Jan 29 00:19:35 2024 +0700
@@ -6,16 +6,16 @@
 let
   sampler = Sampler(magnification: VK_FILTER_NEAREST, minification: VK_FILTER_NEAREST)
   (RT, WT, PT) = (toRGBA("A51931").asPixel, toRGBA("F4F5F8").asPixel, toRGBA("2D2A4A").asPixel)
-  thai = Image(width: 7, height: 5, imagedata: @[
+  thai = Image[RGBAPixel](width: 7, height: 5, imagedata: @[
     RT, RT, RT, RT, RT, RT, RT,
     WT, WT, WT, WT, WT, WT, WT,
     PT, PT, PT, PT, PT, PT, PT,
     WT, WT, WT, WT, WT, WT, WT,
     RT, RT, RT, RT, RT, RT, RT,
   ])
-  swiss = loadImage("flag.png")
+  swiss = loadImage[RGBAPixel]("flag.png")
   doubleTextureMaterial = MaterialType(
-    name:"Double texture",
+    name: "Double texture",
     vertexAttributes: {
       "position": Vec3F32,
       "uv": Vec2F32,
@@ -23,11 +23,11 @@
     attributes: {"tex1": TextureType, "tex2": TextureType}.toTable
   )
   material = initMaterialData(
-    theType=doubleTextureMaterial,
-    name="swiss-thai",
-    attributes={
-      "tex1": initDataList(@[Texture(image: thai, sampler: sampler)]),
-      "tex2": initDataList(@[Texture(image: swiss, sampler: sampler)]),
+    theType = doubleTextureMaterial,
+    name = "swiss-thai",
+    attributes = {
+      "tex1": initDataList(@[Texture(colorImage: thai, sampler: sampler, isGrayscale: false)]),
+      "tex2": initDataList(@[Texture(colorImage: swiss, sampler: sampler, isGrayscale: false)]),
     }
   )
 
@@ -41,23 +41,23 @@
 
   const
     shaderConfiguration1 = createShaderConfiguration(
-      inputs=[
-        attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead),
-        attr[Vec2f]("uv", memoryPerformanceHint=PreferFastRead),
+      inputs = [
+        attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead),
+        attr[Vec2f]("uv", memoryPerformanceHint = PreferFastRead),
       ],
-      intermediates=[
+      intermediates = [
         attr[Vec2f]("uvout"),
       ],
-      uniforms=[attr[float32]("test2", arrayCount=2)],
+      uniforms = [attr[float32]("test2", arrayCount = 2)],
       samplers = @[
-        attr[Texture]("tex1", arrayCount=1),
-        attr[Texture]("tex2", arrayCount=1),
+        attr[Texture]("tex1", arrayCount = 1),
+        attr[Texture]("tex2", arrayCount = 1),
       ],
-      outputs=[attr[Vec4f]("color")],
-      vertexCode="""
+      outputs = [attr[Vec4f]("color")],
+      vertexCode = """
       gl_Position = vec4(position.x, position.y + sin(Uniforms.test2[1]) / Uniforms.test2[1] * 0.5, position.z, 1.0);
       uvout = uv;""",
-      fragmentCode="""
+      fragmentCode = """
       float d = sin(Uniforms.test2[0]) * 0.5 + 0.5;
       color = texture(tex1[0], uvout) * (1 - d) + texture(tex2[0], uvout) * d;
       """,