Skip to content
Go cross-platform OpenGL bindings.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
glutil
test
.travis.yml Travis: Update to target current Go. Nov 28, 2017
LICENSE
README.md
consts.go
doc.go
gl_opengl.go Add GetBoundFramebuffer method. Apr 1, 2016
gl_opengles.go
gl_webgl.go
types_opengl.go
types_opengles.go
types_webgl.go

README.md

gl Build Status GoDoc

Package gl is a Go cross-platform binding for OpenGL, with an OpenGL ES 2-like API.

It supports:

  • macOS, Linux and Windows via OpenGL 2.1 backend,

  • iOS and Android via OpenGL ES 2.0 backend,

  • Modern Browsers (desktop and mobile) via WebGL 1.0 backend.

This is a fork of golang.org/x/mobile/gl package with CL 8793 merged in and Windows support added. This package is fully functional, but may eventually become superceded by the new x/mobile/gl plan. It will exist and be fully supported until it can be safely replaced by a better package.

Installation

go get -u github.com/goxjs/gl/...
GOARCH=js go get -u -d github.com/goxjs/gl/...

Usage

This OpenGL binding has a ContextWatcher, which implements glfw.ContextWatcher interface. Recommended usage is with github.com/goxjs/glfw package, which accepts a ContextWatcher in its Init, and takes on the responsibility of notifying it when context is made current or detached.

if err := glfw.Init(gl.ContextWatcher); err != nil {
	// Handle error.
}
defer glfw.Terminate()

If you're not using a ContextWatcher-aware glfw library, you must call methods of gl.ContextWatcher yourself whenever you make a context current or detached.

window.MakeContextCurrent()
gl.ContextWatcher.OnMakeCurrent(nil)

glfw.DetachCurrentContext()
gl.ContextWatcher.OnDetach()
You can’t perform that action at this time.