Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import ("fmt"
- "runtime"
- "github.com/go-gl/glfw/v3.2/glfw"
- "github.com/go-gl/gl/v3.3-core/gl")
- const (windowWidth = 960
- windowHeight = 540)
- func main() {
- fmt.Printf("launching\n")
- runtime.LockOSThread()
- if err := glfw.Init(); err != nil {
- panic(fmt.Errorf("could not initialize glfw: %v", err))
- }
- fmt.Printf("glfw initialized\n")
- glfw.WindowHint(glfw.ContextVersionMajor, 3)
- glfw.WindowHint(glfw.ContextVersionMinor, 3)
- glfw.WindowHint(glfw.Resizable, glfw.True)
- glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
- glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
- fmt.Printf("glfw hints defined\n")
- win, err := glfw.CreateWindow(windowWidth, windowHeight, "Hello World!", nil, nil)
- if err != nil {
- panic(fmt.Errorf("could not create glfw window: %v", err))
- }
- fmt.Printf("glfw window created\n")
- win.MakeContextCurrent()
- if err := gl.Init(); err != nil {
- panic(fmt.Errorf("opengl init error: %v", err))
- }
- fmt.Printf("opengl context created\n")
- gl.ClearColor(0.0, 0.5, 1.0, 1.0)
- fmt.Printf("launched\n")
- for !win.ShouldClose() {
- gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
- win.SwapBuffers()
- glfw.PollEvents()
- }
- fmt.Printf("closing\n")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement