diff examples/E01_hello_triangle.nim @ 210:f3912838cd69

fix: always use rgba
author Sam <sam@basx.dev>
date Tue, 09 May 2023 18:19:17 +0700
parents 84fd522fdf3f
children ad078e26a1c7
line wrap: on
line diff
--- a/examples/E01_hello_triangle.nim	Tue May 09 01:37:46 2023 +0700
+++ b/examples/E01_hello_triangle.nim	Tue May 09 18:19:17 2023 +0700
@@ -4,9 +4,9 @@
 const
   vertexInput = @[
     attr[Vec3f]("position"),
-    attr[Vec3f]("color"),
+    attr[Vec4f]("color"),
   ]
-  vertexOutput = @[attr[Vec3f]("outcolor")]
+  vertexOutput = @[attr[Vec4f]("outcolor")]
   fragOutput = @[attr[Vec4f]("color")]
   vertexCode = compileGlslShader(
     stage=VK_SHADER_STAGE_VERTEX_BIT,
@@ -21,7 +21,7 @@
     stage=VK_SHADER_STAGE_FRAGMENT_BIT,
     inputs=vertexOutput,
     outputs=fragOutput,
-    main="color = vec4(outcolor, 1);"
+    main="color = outcolor;"
   )
 
 var
@@ -29,7 +29,7 @@
     "triangle",
     newMesh(
       [newVec3f(-0.5, 0.5), newVec3f(0, -0.5), newVec3f(0.5, 0.5)],
-      [X, Y, Z],
+      [newVec4f(1, 0, 0, 1), newVec4f(0, 1, 0, 1), newVec4f(0, 0, 1, 1)],
     )
   ))
   myengine = initEngine("Hello triangle")