blob: 084b8ec58f273923ca8bf407a0dbf6aacc69a415 (
plain)
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
55
56
|
// vim: shiftwidth=4 tabstop=4 noexpandtab
package main
import (
"runtime"
"log"
"flag"
"io/ioutil"
)
type cliArgs struct {
filePath string
debugOutput bool
}
func main() {
// read command line arguments and mute log if necessary
var args cliArgs
args.read()
if !args.debugOutput {
log.SetOutput(ioutil.Discard)
}
// parse STL file
stl, err := ReadBinaryStlFile(args.filePath)
if err != nil {
log.Fatal(err)
}
vertices,vertex_normals = stl.toVertices()
// lock this program to one OS thread (details: https://golang.org/pkg/runtime/#LockOSThread)
log.Println("Locking OS thread")
runtime.LockOSThread()
// initialize application (includes GLFW/window)
var app App = newApp(&stl)
defer app.terminate() // GLFW needs to be terminated!
// initialize graphics
var graphics Graphics = newGraphics()
app.graphics = &graphics // connect graphics to the app
// main loop
for !app.window.ShouldClose() {
graphics.draw()
app.handle()
}
}
func (args *cliArgs) read() {
flag.BoolVar(&args.debugOutput, "debug", false, "enable to print log output")
flag.Parse()
args.filePath = flag.Arg(0)
}
|