// vim: shiftwidth=4 tabstop=4 noexpandtab // stlscope is a file viewer for the STL file format. It is based on Go // and OpenGL. package main import ( "runtime" "log" "flag" "io/ioutil" ) // cliArgs contains all data given via command line arguments. type cliArgs struct { filePath string debugOutput bool } // main represents the whole functionality of stlscope. 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() } } // read reads the command line arguments given to stlscope to a cliArgs struct. func (args *cliArgs) read() { flag.BoolVar(&args.debugOutput, "debug", false, "enable to print log output") flag.Parse() args.filePath = flag.Arg(0) }