package main import ( "runtime" "github.com/go-gl/gl/v4.1-core/gl" "github.com/go-gl/glfw/v3.3/glfw" "github.com/go-gl/mathgl/mgl32" ) const ( start_width = 1920 start_height = 1080 ) func main() { runtime.LockOSThread() if err := glfw.Init(); err != nil { } defer glfw.Terminate() glfw.WindowHint(glfw.ContextVersionMajor, 4) glfw.WindowHint(glfw.ContextVersionMinor, 1) glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) window, err := glfw.CreateWindow(start_width, start_height, "Learning OpenGL", nil, nil) if err != nil { panic(err) } window.MakeContextCurrent() if err := gl.Init(); err != nil { panic(err) } projection := CreateOrthographicProjection(start_width, start_height) InitHLGL(projection) gl.ClearColor(0.2, 0.3, 0.3, 1.0) for !window.ShouldClose() { gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) // DrawRectangleWH(100, 100, 700, 150, HLColorRGBA{255, 0, 0, 255}) // DrawRectangleWH(400, 200, 300, 300, HLColorRGBA{0, 255, 0, 255}) DrawRoundedRectangle(200, 500, 200, 200, 10, HLColorRGBA{0, 0, 255, 255}) window.SwapBuffers() glfw.WaitEvents() } window.Destroy() return } func CreateOrthographicProjection(width, height int) mgl32.Mat4 { return mgl32.Ortho(0, float32(width), 0, float32(height), -1, 1) }