summaryrefslogtreecommitdiff
path: root/app.go
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2021-05-21 13:45:20 +0200
committerxengineering <mail2xengineering@protonmail.com>2021-05-21 13:45:20 +0200
commitc8f8de20f5ff03d94a969e23cfe77d52e10b3ab4 (patch)
tree71014001dac06af40de6ff7936b05e4d1536b637 /app.go
parent0c87cf3f007797714755b309ad31602cedb8af1e (diff)
downloadstlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.tar
stlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.tar.zst
stlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.zip
Refactor GLFW-related Code
Diffstat (limited to 'app.go')
-rw-r--r--app.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/app.go b/app.go
new file mode 100644
index 0000000..603f47d
--- /dev/null
+++ b/app.go
@@ -0,0 +1,55 @@
+// vim: shiftwidth=4 tabstop=4 noexpandtab
+
+package main
+
+import (
+ "log"
+
+ "github.com/go-gl/glfw/v3.3/glfw"
+)
+
+const (
+ WINDOW_WIDTH = 500
+ WINDOW_HEIGHT = 500
+ WINDOW_TITLE = "stlscope"
+)
+
+type App struct {
+ window *glfw.Window
+}
+
+func newApp() App {
+
+ var app App = App{}
+ var err error
+
+ log.Println("GLFW init")
+ if err := glfw.Init(); err != nil {
+ panic(err)
+ }
+
+ glfw.WindowHint(glfw.Resizable, glfw.False)
+ glfw.WindowHint(glfw.ContextVersionMajor, 4)
+ glfw.WindowHint(glfw.ContextVersionMinor, 6)
+ glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
+ glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
+ glfw.WindowHint(glfw.Samples, 16) // anti-aliasing
+
+ log.Println("Creating Window")
+ app.window, err = glfw.CreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, nil, nil)
+ if err != nil {
+ panic(err)
+ }
+ app.window.MakeContextCurrent()
+
+ return app
+}
+
+func (application App) handle() {
+ glfw.PollEvents()
+ application.window.SwapBuffers()
+}
+
+func (application App) terminate() {
+ glfw.Terminate()
+}