Mercurial > games > semicongine
view examples/E01_hello_triangle.nim @ 1140:5934c5615f13
did: update all examples to work with latest refactoring
author | sam <sam@basx.dev> |
---|---|
date | Sat, 08 Jun 2024 15:16:17 +0700 |
parents | 114f395b9144 |
children |
line wrap: on
line source
import std/tables import ../semicongine # shader setup const shaderConfiguration = CreateShaderConfiguration( name = "default shader", inputs = [ Attr[Vec3f]("position"), Attr[Vec4f]("color"), ], intermediates = [Attr[Vec4f]("outcolor")], outputs = [Attr[Vec4f]("color")], vertexCode = "gl_Position = vec4(position, 1.0); outcolor = color;", fragmentCode = "color = outcolor;", ) # scene setup var scene = Scene(name: "scene", meshes: @[NewMesh( positions = [NewVec3f(-0.5, 0.5), NewVec3f(0, -0.5), NewVec3f(0.5, 0.5)], colors = [NewVec4f(1, 0, 0, 1), NewVec4f(0, 1, 0, 1), NewVec4f(0, 0, 1, 1)], material = VERTEX_COLORED_MATERIAL.InitMaterialData() )] ) myengine = InitEngine("Hello triangle", showFps = true) myengine.InitRenderer({VERTEX_COLORED_MATERIAL: shaderConfiguration}, inFlightFrames = 2) myengine.LoadScene(scene) while myengine.UpdateInputs() and not KeyWasPressed(Escape): Transform[Vec3f](scene.meshes[0][], "position", Scale(1.001, 1.001)) myengine.RenderScene(scene) myengine.Destroy()