-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdraw_model_no_pipeline.lua
39 lines (26 loc) · 1.06 KB
/
draw_model_no_pipeline.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
-- Draw models without a pipeline
hg = require("harfang")
hg.InputInit()
hg.WindowSystemInit()
res_x, res_y = 1280, 720
win = hg.RenderInit('Harfang - Draw Models no Pipeline', res_x, res_y, hg.RF_VSync | hg.RF_MSAA4X)
-- vertex layout and models
vtx_layout = hg.VertexLayoutPosFloatNormUInt8()
cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
ground_mdl = hg.CreatePlaneModel(vtx_layout, 5, 5, 1, 1)
shader = hg.LoadProgramFromFile('resources_compiled/shaders/mdl')
-- main loop
angle = 0
while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
dt = hg.TickClock()
angle = angle + hg.time_to_sec_f(dt)
viewpoint = hg.TranslationMat4(hg.Vec3(0, 1, -3))
hg.SetViewPerspective(0, 0, 0, res_x, res_y, viewpoint)
hg.DrawModel(0, cube_mdl, shader, {}, {}, hg.TransformationMat4(hg.Vec3(0, 1, 0), hg.Vec3(angle, angle, angle)))
hg.DrawModel(0, ground_mdl, shader, {}, {}, hg.TranslationMat4(hg.Vec3(0, 0, 0)))
hg.Frame()
hg.UpdateWindow(win)
-- prevent GC bottleneck
collectgarbage()
end
hg.RenderShutdown()