Skip to content

Instantly share code, notes, and snippets.

@drgomesp
Last active March 15, 2020 03:28
Show Gist options
  • Save drgomesp/d346d0d354f48b93c926a762afeaf62f to your computer and use it in GitHub Desktop.
Save drgomesp/d346d0d354f48b93c926a762afeaf62f to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"runtime"
"github.com/go-gl/gl/v4.1-core/gl"
"github.com/go-gl/glfw/v3.2/glfw"
)
const (
windowWidth = 960
windowHeight = 540
)
func main() {
runtime.LockOSThread()
if err := glfw.Init(); err != nil {
panic(fmt.Errorf("could not initialize glfw: %v", err))
}
glfw.WindowHint(glfw.ContextVersionMajor, 4)
glfw.WindowHint(glfw.ContextVersionMinor, 1)
glfw.WindowHint(glfw.Resizable, glfw.True)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
win, err := glfw.CreateWindow(800, 600, "Hello world", nil, nil)
if err != nil {
panic(fmt.Errorf("could not create opengl renderer: %v", err))
}
win.MakeContextCurrent()
if err := gl.Init(); err != nil {
panic(err)
}
gl.ClearColor(0, 0.5, 1.0, 1.0)
for !win.ShouldClose() {
gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
win.SwapBuffers()
glfw.PollEvents()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment