Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 652:43240986f76d
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 | 164bf40c664f |
children | 659992f14dd6 |
comparison
equal
deleted
inserted
replaced
651:164bf40c664f | 652:43240986f76d |
---|---|
115 attr[Vec3f]("color", memoryPerformanceHint=PreferFastWrite), | 115 attr[Vec3f]("color", memoryPerformanceHint=PreferFastWrite), |
116 attr[Vec3f]("translate", perInstance=true) | 116 attr[Vec3f]("translate", perInstance=true) |
117 ] | 117 ] |
118 vertexOutput = @[attr[Vec3f]("outcolor")] | 118 vertexOutput = @[attr[Vec3f]("outcolor")] |
119 uniforms = @[attr[float32]("time")] | 119 uniforms = @[attr[float32]("time")] |
120 # samplers = @[attr[Sampler2DType]("my_little_texture")] | 120 samplers = @[attr[Sampler2DType]("my_little_texture")] |
121 fragOutput = @[attr[Vec4f]("color")] | 121 fragOutput = @[attr[Vec4f]("color")] |
122 vertexCode = compileGlslShader( | 122 vertexCode = compileGlslShader( |
123 stage=VK_SHADER_STAGE_VERTEX_BIT, | 123 stage=VK_SHADER_STAGE_VERTEX_BIT, |
124 inputs=vertexInput, | 124 inputs=vertexInput, |
125 uniforms=uniforms, | 125 uniforms=uniforms, |
126 # samplers=samplers, | 126 samplers=samplers, |
127 outputs=vertexOutput, | 127 outputs=vertexOutput, |
128 main="""gl_Position = vec4(position + translate, 1.0); outcolor = color;""" | 128 main="""gl_Position = vec4(position + translate, 1.0); outcolor = color;""" |
129 ) | 129 ) |
130 fragmentCode = compileGlslShader( | 130 fragmentCode = compileGlslShader( |
131 stage=VK_SHADER_STAGE_FRAGMENT_BIT, | 131 stage=VK_SHADER_STAGE_FRAGMENT_BIT, |
132 inputs=vertexOutput, | 132 inputs=vertexOutput, |
133 uniforms=uniforms, | 133 uniforms=uniforms, |
134 # samplers=samplers, | 134 samplers=samplers, |
135 outputs=fragOutput, | 135 outputs=fragOutput, |
136 # main="color = texture(my_little_texture, outcolor.xy) * 0.5 + vec4(outcolor, 1) * 0.5;" | 136 main="color = texture(my_little_texture, outcolor.xy) * 0.5 + vec4(outcolor, 1) * 0.5;" |
137 main="color = vec4(outcolor, 1) * 0.5;" | |
138 ) | 137 ) |
139 var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) | 138 var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) |
140 engine.setRenderer(renderPass) | 139 engine.setRenderer(renderPass) |
141 | 140 |
142 # INIT SCENES | 141 # INIT SCENES |
145 newScene("different mesh types", scene_different_mesh_types()), | 144 newScene("different mesh types", scene_different_mesh_types()), |
146 newScene("primitives", scene_primitives()) | 145 newScene("primitives", scene_primitives()) |
147 ] | 146 ] |
148 for scene in scenes.mitems: | 147 for scene in scenes.mitems: |
149 scene.addShaderGlobal("time", 0.0'f32) | 148 scene.addShaderGlobal("time", 0.0'f32) |
149 let (R, W) = ([0'u8, 0'u8, 0'u8, 0'u8], [0'u8, 0'u8, 0'u8, 0'u8]) | |
150 scene.addTexture("my_little_texture", TextureImage(width: 5, height: 5, imagedata: @[ | |
151 R, R, R, R, R, | |
152 R, R, R, R, R, | |
153 R, R, R, R, R, | |
154 R, R, R, R, R, | |
155 R, R, R, R, R, | |
156 ])) | |
150 engine.addScene(scene, vertexInput) | 157 engine.addScene(scene, vertexInput) |
151 | 158 |
152 # MAINLOOP | 159 # MAINLOOP |
153 echo "Setup successfull, start rendering" | 160 echo "Setup successfull, start rendering" |
154 for i in 0 ..< 3: | 161 for i in 0 ..< 3: |