diff tests/test_vulkan_wrapper.nim @ 191:81dc05b46b85

add: texture testing, not working yet, something update un-updated descritors (even though we write the descriptors man!)
author Sam <sam@basx.dev>
date Sat, 06 May 2023 01:37:33 +0700
parents 8f2eaf0d2808
children 659992f14dd6
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim	Fri May 05 23:57:56 2023 +0700
+++ b/tests/test_vulkan_wrapper.nim	Sat May 06 01:37:33 2023 +0700
@@ -117,13 +117,13 @@
     ]
     vertexOutput = @[attr[Vec3f]("outcolor")]
     uniforms = @[attr[float32]("time")]
-    # samplers = @[attr[Sampler2DType]("my_little_texture")]
+    samplers = @[attr[Sampler2DType]("my_little_texture")]
     fragOutput = @[attr[Vec4f]("color")]
     vertexCode = compileGlslShader(
       stage=VK_SHADER_STAGE_VERTEX_BIT,
       inputs=vertexInput,
       uniforms=uniforms,
-      # samplers=samplers,
+      samplers=samplers,
       outputs=vertexOutput,
       main="""gl_Position = vec4(position + translate, 1.0); outcolor = color;"""
     )
@@ -131,10 +131,9 @@
       stage=VK_SHADER_STAGE_FRAGMENT_BIT,
       inputs=vertexOutput,
       uniforms=uniforms,
-      # samplers=samplers,
+      samplers=samplers,
       outputs=fragOutput,
-      # main="color = texture(my_little_texture, outcolor.xy) * 0.5 + vec4(outcolor, 1) * 0.5;"
-      main="color = vec4(outcolor, 1) * 0.5;"
+      main="color = texture(my_little_texture, outcolor.xy) * 0.5 + vec4(outcolor, 1) * 0.5;"
     )
   var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode)
   engine.setRenderer(renderPass)
@@ -147,6 +146,14 @@
   ]
   for scene in scenes.mitems:
     scene.addShaderGlobal("time", 0.0'f32)
+    let (R, W) = ([0'u8, 0'u8, 0'u8, 0'u8], [0'u8, 0'u8, 0'u8, 0'u8])
+    scene.addTexture("my_little_texture", TextureImage(width: 5, height: 5, imagedata: @[
+      R, R, R, R, R,
+      R, R, R, R, R,
+      R, R, R, R, R,
+      R, R, R, R, R,
+      R, R, R, R, R,
+    ]))
     engine.addScene(scene, vertexInput)
 
   # MAINLOOP