Go bindings for OpenGL (generated via glow)
Go
Switch branches/tags
Nothing to show
Clone or download
shurcooL and errcw all: Regenerate all bindings with new XML data. (#95)
Done with:

	go generate -tags=gen

Follows go-gl/glow#96.
Latest commit 68e2537 Apr 7, 2018
Permalink
Failed to load latest commit information.
all-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v2.1/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v3.1/gles2 all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v3.2-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v3.2-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v3.3-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v3.3-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.1-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.1-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.2-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.2-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.3-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.3-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.4-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.4-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.5-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.5-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.6-compatibility/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
v4.6-core/gl all: Regenerate all bindings with new XML data. (#95) Apr 7, 2018
.travis.yml Travis: Update Go versions. (#73) May 11, 2017
LICENSE Initial commit Apr 10, 2014
README.md Add v4.6-{core,compatibility}/gl prebuilt packages for OpenGL 4.6. (#92) Mar 4, 2018
generate.go Add v4.6-{core,compatibility}/gl prebuilt packages for OpenGL 4.6. (#92) Mar 4, 2018

README.md

gl Build Status GoDoc

This repository holds Go bindings to various OpenGL versions. They are auto-generated using Glow.

Features:

  • Go functions that mirror the C specification using Go types.
  • Support for multiple OpenGL APIs (GL/GLES/EGL/WGL/GLX/EGL), versions, and profiles.
  • Support for extensions (including debug callbacks).

Requirements:

  • A cgo compiler (typically gcc).
  • On Ubuntu/Debian-based systems, the libgl1-mesa-dev package.

Usage

Use go get -u to download and install the prebuilt packages. The prebuilt packages support OpenGL versions 2.1, 3.1, 3.2, 3.3, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6 across both the core and compatibility profiles and include all extensions. Pick whichever one(s) you need:

go get -u github.com/go-gl/gl/v{3.2,3.3,4.1,4.2,4.3,4.4,4.5,4.6}-{core,compatibility}/gl
go get -u github.com/go-gl/gl/v3.1/gles2
go get -u github.com/go-gl/gl/v2.1/gl

Once the bindings are installed you can use them with the appropriate import statements.

import "github.com/go-gl/gl/v3.3-core/gl"

func main() {
	window := ... // Open a window.
	window.MakeContextCurrent()

	// Important! Call gl.Init only under the presence of an active OpenGL context,
	// i.e., after MakeContextCurrent.
	if err := gl.Init(); err != nil {
		log.Fatalln(err)
	}
}

The gl package contains the OpenGL functions and enumeration values for the imported version. It also contains helper functions for working with the API. Of note is gl.Ptr which takes a Go array or slice or pointer and returns a corresponding uintptr to use with functions expecting data pointers. Also of note is gl.Str which takes a null-terminated Go string and returns a corresponding *int8 to use with functions expecting character pointers.

A note about threading and goroutines. The bindings do not expose a mechanism to make an OpenGL context current on a different thread so you must restrict your usage to the thread on which you called gl.Init(). To do so you should use LockOSThread.

Examples

Examples illustrating how to use the bindings are available in the example repo. There are examples for OpenGL 4.1 core and OpenGL 2.1.

Function Loading

The procaddr package contains platform-specific functions for loading OpenGL functions. Calling gl.Init() uses the auto subpackage to automatically select an appropriate implementation based on the build environment. If you want to select a specific implementation you can use the noauto build tag and the gl.InitWithProcAddrFunc initialization function.

Generating

These gl bindings are generated using the Glow generator. Only developers of this repository need to do this step.

It is required to have glow source in the same Go workspace (since relative paths are used) and the glow binary should be in your $PATH. Doable with go get -u github.com/go-gl/glow if your $GOPATH/bin is in your $PATH.

go generate -tags=gen github.com/go-gl/gl

More information about these bindings can be found in the Glow repository.