summaryrefslogtreecommitdiff
path: root/graphics.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 /graphics.go
parent0c87cf3f007797714755b309ad31602cedb8af1e (diff)
downloadstlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.tar
stlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.tar.zst
stlscope-c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4.zip
Refactor GLFW-related Code
Diffstat (limited to 'graphics.go')
-rw-r--r--graphics.go33
1 files changed, 1 insertions, 32 deletions
diff --git a/graphics.go b/graphics.go
index 812be3a..6cb3400 100644
--- a/graphics.go
+++ b/graphics.go
@@ -8,7 +8,6 @@ import (
"strings"
"github.com/go-gl/gl/v4.6-core/gl"
- "github.com/go-gl/glfw/v3.3/glfw"
)
var (
@@ -21,10 +20,6 @@ var (
)
const (
- WINDOW_WIDTH = 500
- WINDOW_HEIGHT = 500
- WINDOW_TITLE = "stlscope"
-
// vertex shader to draw points
VERTEX_SHADER = `
#version 410
@@ -44,29 +39,6 @@ const (
` + "\x00"
)
-func initGlfw() *glfw.Window {
- 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
-
- window, err := glfw.CreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_TITLE, nil, nil)
- if err != nil {
- panic(err)
- }
- window.MakeContextCurrent()
-
- return window
-}
-
// initOpenGL initializes OpenGL and returns an intiialized program
func initOpenGL() uint32 {
log.Println("OpenGL init")
@@ -93,15 +65,12 @@ func initOpenGL() uint32 {
return prog
}
-func draw(vao uint32, window *glfw.Window, program uint32) {
+func draw(vao uint32, program uint32) {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
gl.UseProgram(program)
gl.BindVertexArray(vao)
gl.DrawArrays(gl.TRIANGLES, 0, int32(len(triangle)/3))
-
- glfw.PollEvents()
- window.SwapBuffers()
}
// makeVao initializes and returns a vertex array from the points provided.