Solod bindings for glfw, a multi-platform library for OpenGL, OpenGL ES and Vulkan development.
-
Install glfw for your operating system.
-
Install the Solod bindings.
go get solod.dev/glfw@latest
- Use it in your code.
package main
import (
"solod.dev/glfw/libglfw"
"solod.dev/so/c"
"solod.dev/so/fmt"
"solod.dev/so/os"
)
func main() {
if libglfw.Init() == 0 {
fmt.Println("Can't initialize glfw")
os.Exit(1)
}
defer libglfw.Terminate()
fmt.Println("glfw version:", c.String(libglfw.GetVersionString()))
}The bindings cover glfw itself, not OpenGL. glfw opens the window and creates the GL context; the drawing calls (glClear and friends) come from the OpenGL headers, so declare the ones you use in your own package:
//so:include <OpenGL/gl.h>
//so:extern GL_COLOR_BUFFER_BIT
var GL_COLOR_BUFFER_BIT c.UInt
//so:extern glClear
func glClear(mask c.UInt)Linking them is up to the build: -framework OpenGL on macOS, -lGL elsewhere. See example/simple/extern.go and the Makefile.