comparison tests/test_mesh.nim @ 777:754835bf175e

add: changing rendering system, not finished yet, also upgrading to Nim 2
author Sam <sam@basx.dev>
date Mon, 07 Aug 2023 00:23:00 +0700
parents a4c757f5d17f
children e656c0aad093
comparison
equal deleted inserted replaced
776:002d9c576756 777:754835bf175e
3 proc main() = 3 proc main() =
4 var ent1 = newEntity("hoho", {"mesh": Component(rect())}) 4 var ent1 = newEntity("hoho", {"mesh": Component(rect())})
5 var ent2 = newEntity("hehe", [], ent1) 5 var ent2 = newEntity("hehe", [], ent1)
6 var myScene = newScene("hi", ent2) 6 var myScene = newScene("hi", ent2)
7 myScene.root.transform = translate3d(0.2'f32, 0'f32, 0'f32) 7 myScene.root.transform = translate3d(0.2'f32, 0'f32, 0'f32)
8 myScene.root.children[0].transform = translate3d(0'f32, 0.2'f32, 0'f32) 8 myScene.root[0].transform = translate3d(0'f32, 0.2'f32, 0'f32)
9 var scenes = [ 9 var scenes = [
10 # loadScene("default_cube.glb", "1"), 10 # loadScene("default_cube.glb", "1"),
11 # loadScene("default_cube1.glb", "3"), 11 # loadScene("default_cube1.glb", "3"),
12 # loadScene("default_cube2.glb", "4"), 12 # loadScene("default_cube2.glb", "4"),
13 # loadScene("flat.glb", "5"), 13 # loadScene("flat.glb", "5"),
53 color = texture(baseColorTexture[materialId], colorTexCoord) * vertexColor; 53 color = texture(baseColorTexture[materialId], colorTexCoord) * vertexColor;
54 """ 54 """
55 ) 55 )
56 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=newVec4f(0, 0, 0, 1))) 56 engine.setRenderer(engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode, clearColor=newVec4f(0, 0, 0, 1)))
57 for scene in scenes.mitems: 57 for scene in scenes.mitems:
58 engine.addScene(scene, vertexInput, samplers, transformAttribute="transform") 58 engine.addScene(scene, vertexInput, samplers, transformAttribute="transform", materialIndexAttribute="")
59 scene.addShaderGlobal("projection", Unit4) 59 scene.addShaderGlobal("projection", Unit4)
60 scene.addShaderGlobal("view", Unit4) 60 scene.addShaderGlobal("view", Unit4)
61 var 61 var
62 size = 1'f32 62 size = 1'f32
63 elevation = 0'f32 63 elevation = 0'f32