Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 60 lines (39 sloc) 3.073 kB
89cb87f @shurcooL Add README.md tailored for new gl repo.
shurcooL authored
1 GL
2 ==
3
4 This repository holds Go bindings to various OpenGL versions. They are auto-generated using [Glow](github.com/go-gl/glow).
5
6 Features:
7 - Go functions that mirror the C specification using Go types.
8 - Support for multiple OpenGL APIs (GL/GLES/EGL/WGL/GLX/EGL), versions, and profiles.
9 - Support for extensions (including debug callbacks).
10
0f03aa6 @errcw Add requirements to README
errcw authored
11 Requirements:
12 - A cgo compiler (typically gcc)
13
89cb87f @shurcooL Add README.md tailored for new gl repo.
shurcooL authored
14 Usage
15 -----
16
17 Use `go get` to download and install one of the prebuilt packages. The prebuilt packages support OpenGL versions 3.2, 3.3, 4.1, 4.4 and 4.5 across both the core and compatibility profiles and include all extensions.
18
19 go get github.com/go-gl/gl/v{3.2,3.3,4.1,4.4,4.5}-{core,compatibility}/gl
20 go get github.com/go-gl/gl/v3.3-core/gl
21
22 Once the bindings are installed you can use them with the appropriate import statements.
23
24 ```Go
25 import "github.com/go-gl/gl/v3.3-core/gl"
26
27 func main() {
28 if err := gl.Init(); err != nil {
29 panic(err)
30 }
31 }
32 ```
33
34 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.
35
36 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](https://code.google.com/p/go-wiki/wiki/LockOSThread).
37
38 Examples
39 --------
40
d61248e @shurcooL Point to example folder (with readme) more consistently.
shurcooL authored
41 Examples illustrating how to use the bindings are available in the [examples](https://github.com/go-gl/examples) repo. There are examples for [OpenGL 4.1 core](https://github.com/go-gl/examples/blob/master/glfw31-gl41core-cube) and [OpenGL 2.1](https://github.com/go-gl/examples/tree/master/glfw31-gl21-cube).
89cb87f @shurcooL Add README.md tailored for new gl repo.
shurcooL authored
42
fc33298 @shurcooL Move section from glow README to here.
shurcooL authored
43 Function Loading
44 ----------------
45
46 The `procaddr` package contains platform-specific functions for [loading OpenGL functions](https://www.opengl.org/wiki/Load_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.
47
6b3845f @shurcooL Use go generate directives for generation.
shurcooL authored
48 Generating
49 ----------
50
df6d1ee @shurcooL README: Improve wording in Generating section.
shurcooL authored
51 These gl bindings are generated using the [Glow](https://github.com/go-gl/glow) generator. Only developers of this repository need to do this step.
396528a @shurcooL Note go generate dependency (on glow).
shurcooL authored
52
df6d1ee @shurcooL README: Improve wording in Generating section.
shurcooL authored
53 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`.
6b3845f @shurcooL Use go generate directives for generation.
shurcooL authored
54
55 ```bash
56 go generate -tags=gen github.com/go-gl/gl
57 ```
89cb87f @shurcooL Add README.md tailored for new gl repo.
shurcooL authored
58
59 More information about these bindings can be found in the [Glow repository](https://github.com/go-gl/glow).
Something went wrong with that request. Please try again.