myou-engine/tests/msaa2.nim

30 lines
1 KiB
Nim

import myou_engine
import random
# Create engine, scene, camera
let engine = newMyouEngine(1024, 768)
let scene = engine.newScene()
let cam = scene.newCamera(cam_type = Orthographic, ortho_scale = 2)
# This method allows changing the amount of antialiasing samples at any point,
# and it will resize, add or remove the multisampled framebuffer
engine.screen.set_MSAA_samples 4
# Move the camera upwards (the default rotation looks down)
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()