28 lines
917 B
Nim
28 lines
917 B
Nim
|
|
import myou_engine
|
|
|
|
# Create engine, scene, camera
|
|
let engine = newMyouEngine(1024, 768)
|
|
let scene = engine.newScene()
|
|
let cam = scene.newCamera() # this sets the active camera if there's none
|
|
|
|
# Move the camera upwards (the default rotation looks down)
|
|
cam.position.z = 10
|
|
|
|
# The default layout is vertex position (vec3) and color (uint8 RGBA).
|
|
# This seq can be of any type as long as it matches the underlying mesh layout.
|
|
let vertices = @[
|
|
(vec3(-1.2, -1, 0), [255'u8, 255, 0, 255]),
|
|
(vec3( 1.2, -1, 0), [0'u8, 255, 255, 255]),
|
|
(vec3( 0, 1, 0), [255'u8, 0, 255, 255]),
|
|
]
|
|
let triangle = scene.newMesh("triangle", vertex_array=vertices)
|
|
|
|
# A predefined material that just draws the vertex colors
|
|
triangle.materials.add engine.newVertexColorMaterial()
|
|
|
|
# A new scene is disabled by default, we need to enable it
|
|
scene.enable_render()
|
|
|
|
# This should be the last line of code of the main module
|
|
engine.run()
|