blob: 35a4704d1a0bbe14604d0a314686bfcee125667e (
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
|
// vim: shiftwidth=4 tabstop=4 noexpandtab
package main
import (
"runtime"
"log"
"flag"
"github.com/go-gl/glfw/v3.3/glfw"
)
var (
stlFilePath string
)
func main() {
// read command line arguments
parseFlags()
// parse STL file
_, err := ReadBinaryStlFile(stlFilePath)
if err != nil {
log.Fatal(err)
}
// lock this program to one OS thread (details: https://golang.org/pkg/runtime/#LockOSThread)
log.Println("Locking OS thread")
runtime.LockOSThread()
// init GLFW and assert termination at end of main
window := initGlfw()
defer glfw.Terminate()
// init OpenGL
program := initOpenGL()
vao := makeVao(triangle)
// main loop
for !window.ShouldClose() {
draw(vao, window, program)
}
}
func parseFlags() {
flag.StringVar(&stlFilePath, "file", "myfile.stl", "path to the binary STL file")
flag.Parse()
}
|