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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
require 'honey.std'
local gl = honey.gl
-- initialize honey
honey.init()
local db = honey.ecs.EntityDb()
local systems = honey.ecs.SystemDb(db)
systems:addSystems(honey.ecs.node.system)
systems:addSystems(honey.ecs.render.system)
systems:addSystems(honey.ecs.script.system)
-- camera
db:createEntityWithComponents{
node = {
matrix = Mat4()
:identity()
:translate(Vec3{0,0,10}),
},
camera = {
projection = Mat4()
:perspective(90, 640/480, 0.1, 1000)
},
}
-- mesh
db:createEntityWithComponents{
node = {
matrix = Mat4()
:identity(),
},
renderMesh = {
mesh = {
filename = "assets/dodecahedron.obj",
index = 1,
},
textures = {
ourTexture = { filename = "assets/green-grass.jpg" },
},
shader = { vertex="vertex.glsl", fragment="fragment.glsl" },
},
}
honey.loop(function(dt)
gl.ClearColor(0.2, 0.4, 1.0, 1.0)
gl.Clear(gl.COLOR_BUFFER_BIT + gl.DEPTH_BUFFER_BIT + gl.STENCIL_BUFFER_BIT)
systems:update(dt)
end)
-- clean up
honey.terminate()
|