-
Notifications
You must be signed in to change notification settings - Fork 0
/
gl3d.go
50 lines (42 loc) · 1.02 KB
/
gl3d.go
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
package main
import (
"github.com/hersle/gl3d/engine"
"github.com/hersle/gl3d/object"
"github.com/hersle/gl3d/math"
"github.com/hersle/gl3d/light"
"github.com/hersle/gl3d/input"
"flag"
"runtime/pprof"
"os"
)
var cpuprofile = flag.String("cpuprofile", "", "write CPU profile to file")
func main() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
panic(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
eng := engine.NewEngine()
eng.InitializeCustom = func() {
eng.Scene.AddAmbientLight(light.NewAmbientLight(math.Vec3{0.5, 0.5, 0.5}))
eng.Scene.AddPointLight(light.NewPointLight(math.Vec3{1, 1, 1}))
eng.Scene.PointLights[0].Attenuation = 0.001
for _, filename := range flag.Args() {
model, err := object.ReadMesh(filename)
if err != nil {
panic(err)
}
eng.Scene.AddMesh(model)
}
}
input.KeySpace.Listen(func(action input.Action) {
if !eng.ConsoleActive {
eng.Scene.PointLights[0].Place(eng.Camera.Position)
}
})
eng.Run()
}