From fbd513c7c2531c12fcd7e81bd4ce66c5ec5f6902 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 20 May 2021 12:16:36 +0200 Subject: Implement STL Parsing --- main.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 main.go (limited to 'main.go') diff --git a/main.go b/main.go new file mode 100644 index 0000000..35a4704 --- /dev/null +++ b/main.go @@ -0,0 +1,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() +} -- cgit v1.2.3-70-g09d2