25 lines
846 B
Nim
25 lines
846 B
Nim
|
|
import myou_engine
|
|
import random
|
|
|
|
# Create engine, scene, camera
|
|
let engine = newMyouEngine(1024, 768, context_msaa_samples=4)
|
|
let scene = engine.newScene()
|
|
let cam = scene.newCamera(cam_type = Orthographic, ortho_scale = 2)
|
|
|
|
cam.position.z = 10
|
|
|
|
# vertex_count is the initial capacity and is not necessary
|
|
let lines = scene.newMesh("lines", draw_method=Lines, vertex_count=64)
|
|
lines.materials.add engine.newSolidMaterial("white", vec4(1))
|
|
|
|
scene.pre_draw_callbacks.add proc(scene: Scene, dt: float) =
|
|
# ensure_capacity enlarges the size of the mesh if the next N vertices
|
|
# don't fit, by making it at least twice the size
|
|
lines.ensure_capacity(1)
|
|
lines.add_vertex(vec3(rand(1f), rand(1f), 0) * 2f - 1f)
|
|
# call update_varray() only once after making changes
|
|
lines.data.update_varray()
|
|
|
|
scene.enable_render()
|
|
engine.run()
|