From c8f8de20f5ff03d94a969e23cfe77d52e10b3ab4 Mon Sep 17 00:00:00 2001 From: xengineering Date: Fri, 21 May 2021 13:45:20 +0200 Subject: Refactor GLFW-related Code --- graphics.go | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) (limited to 'graphics.go') 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. -- cgit v1.2.3-70-g09d2