comparison tests/test_mesh.nim @ 1138:02e1d2658ff5

did: more renaming
author sam <sam@basx.dev>
date Tue, 04 Jun 2024 22:08:48 +0700
parents a4aa9f374d44
children 114f395b9144
comparison
equal deleted inserted replaced
1137:a4aa9f374d44 1138:02e1d2658ff5
14 proc main() = 14 proc main() =
15 var scenes = [ 15 var scenes = [
16 Scene(name: "Donut", meshes: loadMeshes("donut.glb", MeshMaterial)[0].toSeq), 16 Scene(name: "Donut", meshes: loadMeshes("donut.glb", MeshMaterial)[0].toSeq),
17 ] 17 ]
18 18
19 var engine = initEngine("Test meshes") 19 var engine = InitEngine("Test meshes")
20 const 20 const
21 shaderConfiguration = createShaderConfiguration( 21 shaderConfiguration = createShaderConfiguration(
22 name = "default shader", 22 name = "default shader",
23 inputs = [ 23 inputs = [
24 Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead), 24 Attr[Vec3f]("position", memoryPerformanceHint = PreferFastRead),
44 colorTexCoord = texcoord_0; 44 colorTexCoord = texcoord_0;
45 materialIndexOut = {MATERIALINDEX_ATTRIBUTE}; 45 materialIndexOut = {MATERIALINDEX_ATTRIBUTE};
46 """, 46 """,
47 fragmentCode = "color = texture(baseTexture[materialIndexOut], colorTexCoord) * vertexColor;" 47 fragmentCode = "color = texture(baseTexture[materialIndexOut], colorTexCoord) * vertexColor;"
48 ) 48 )
49 engine.initRenderer({MeshMaterial: shaderConfiguration}) 49 engine.InitRenderer({MeshMaterial: shaderConfiguration})
50 50
51 for scene in scenes.mitems: 51 for scene in scenes.mitems:
52 scene.addShaderGlobal("projection", Unit4F32) 52 scene.addShaderGlobal("projection", Unit4F32)
53 scene.addShaderGlobal("view", Unit4F32) 53 scene.addShaderGlobal("view", Unit4F32)
54 engine.loadScene(scene) 54 engine.LoadScene(scene)
55 55
56 var 56 var
57 size = 1'f32 57 size = 1'f32
58 elevation = 0'f32 58 elevation = 0'f32
59 azimut = 0'f32 59 azimut = 0'f32
85 scenes[currentScene].setShaderGlobal("projection", Perspective(PI / 2, ratio, -0.5, 1)) 85 scenes[currentScene].setShaderGlobal("projection", Perspective(PI / 2, ratio, -0.5, 1))
86 scenes[currentScene].setShaderGlobal( 86 scenes[currentScene].setShaderGlobal(
87 "view", 87 "view",
88 Scale(size, size, size) * Rotate(elevation, NewVec3f(1, 0, 0)) * Rotate(azimut, Yf32) 88 Scale(size, size, size) * Rotate(elevation, NewVec3f(1, 0, 0)) * Rotate(azimut, Yf32)
89 ) 89 )
90 engine.renderScene(scenes[currentScene]) 90 engine.RenderScene(scenes[currentScene])
91 engine.destroy() 91 engine.Destroy()
92 92
93 when isMainModule: 93 when isMainModule:
94 main() 94 main()