- Notifications
You must be signed in to change notification settings - Fork24
Go binding generator for OpenGL
License
go-gl/glow
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Glow is an OpenGL binding generator for Go. Glow parses theOpenGL XML API registry and theEGL XML API registry to produce a machine-generated cgo bridge between Go functions and native OpenGL functions. Glow is a fork ofGoGL2.
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).
- Support for overloads to provide Go functions with different parameter signatures.
See theopen issues for caveats about the current state of the implementation.
Generated OpenGL binding packages are available in thego-gl/gl repository.
See subdirectoryxml/overload
for examples. The motivation here is to provide Go functions with different parameter signatures of existing OpenGL functions.
For example,glVertexAttribPointer(..., void *)
cannot be used withgl.VertexAttribPointer(..., unsafe.Pointer)
when using arbitrary offset values. Thecheckptr
safeguard will abort the program when doing so.Overloads allow the creation of an additionalgl.VertexAttribPointerWithOffset(..., uintptr)
, which calls the original OpenGL function with appropriate casts.
If the prebuilt, go-gettable packages are not suitable for your needs you can build your own. For example,
go get github.com/go-gl/glowcd $GOPATH/src/github.com/go-gl/glowgo build./glow download./glow generate -api=gl -version=3.3 -profile=core -remext=GL_ARB_cl_eventgo install ./gl-core/3.3/gl
NOTE: You will have to provide a GitHub token (personal access or OAuth2 token) to update the XML specification files.
A few notes about the flags togenerate
:
api
: One ofgl
,gles1
,gles2
,egl
,wgl
, orglx
.version
: The API version to generate. Theall
pseudo-version includes all functions and enumerations for the specified API.profile
: Forgl
packages with version 3.2 or higher,core
orcompatibility
(explanation).xml
: The XML directory.tmpl
: The template directory.out
: The output directory for generated files.addext
: If non-empty, a regular expression describing which extensions to includein addition to those supported by the selected profile. Empty by default, including nothing additional. Takes precedence over explicit removal.remext
: If non-empty, a regular expression describing which extensions to exclude. Empty by default, excluding nothing.restrict
: A JSON file that explicitly lists what enumerations / functions that Glow should generate (see example.json).lenientInit
: Flag to disable strict function availability checks atInit
time. By default if any non-extension function pointer cannot be loaded then initialization fails; when this flag is set initialization will succeed with missing functions. Note that on some platforms unavailable functions will load successfully even but fail upon invocation so check against the OpenGL context what is supported.