Check in the GLFW sources.
135 files changed
tree: c66daf131a97b7a2ab3c565a7d536d41ceb95a7a
  1. glfw/
  2. v3.0/
  3. AUTHORS
  4. clipboard.go
  5. context.go
  6. error.c
  7. error.go
  8. glfw.go
  9. input.c
  10. input.go
  11. LICENSE
  12. monitor.c
  13. monitor.go
  14. native_darwin.go
  15. native_linbsd.go
  16. native_windows.go
  17. README.md
  18. time.go
  19. util.go
  20. window.c
  21. window.go
README.md

Go Bindings for GLFW 3

  • ATTENTION: As of GLFW 3.1 we break API. See Changelog below.
  • See here for documentation.
  • You can help by submitting examples to go-gl/examples.

Remarks

  • Mingw64 users should rename glfw3dll.a to libglfw3dll.a.
  • In Windows and Linux, if you compile GLFW yourself, use -DBUILD_SHARED_LIBS=on with cmake in order to build the dynamic libraries.
  • Some functions -which are marked in the documentation- can be called only from the main thread. You need to use runtime.LockOSThread() to arrange that main() runs on main thread.
  • In OS X, you can install Go and GLFW via Homebrew.
$ brew install go
$ brew tap homebrew/versions
$ brew install --build-bottle --static glfw3
$ go get github.com/go-gl/glfw3

Example

package main

import (
	"runtime"

	glfw "github.com/go-gl/glfw3"
)

func init() {
	runtime.LockOSThread()
}

func main() {
	err := glfw.Init()
	if err != nil {
		panic(err)
	}
	defer glfw.Terminate()

	window, err := glfw.CreateWindow(640, 480, "Testing", nil, nil)
	if err != nil {
		panic(err)
	}

	window.MakeContextCurrent()

	for !window.ShouldClose() {
		// Do OpenGL stuff
		window.SwapBuffers()
		glfw.PollEvents()
	}
}

Changelog

  • SetErrorCallback This function is removed. The callback is now set internally. Functions return an error with corresponding code and description (do a type assertion to GlfwError for accessing the variables).
  • Init Returns an error instead of bool.
  • GetTime Returns an error.
  • GetCurrentContext No longer returns an error.
  • GetJoystickAxes No longer returns an error.
  • GetJoystickButtons No longer returns an error.
  • GetJoystickName No longer returns an error.
  • window.GetMonitor No longer returns an error.
  • window.GetAttribute Returns an error.
  • window.SetCharacterCallback Accepts rune instead of uint.
  • window.SetDropCallback added.
  • window.SetCharacterModsCallback added.
  • PostEmptyEvent added.
  • Native window and context handlers added.
  • Constant ApiUnavailable changed to APIUnavailable.
  • Constant ClientApi changed to ClientAPI.
  • Constant OpenglForwardCompatible changed to OpenGLForwardCompatible.
  • Constant OpenglDebugContext changed to OpenGLDebugContext.
  • Constant OpenglProfile changed to OpenGLProfile.
  • Constant SrgbCapable changed to SRGBCapable.
  • Constant OpenglApi changed to OpenGLAPI.
  • Constant OpenglEsApi changed to OpenGLESAPI.
  • Constant OpenglAnyProfile changed to OpenGLAnyProfile.
  • Constant OpenglCoreProfile changed to OpenGLCoreProfile.
  • Constant OpenglCompatProfile changed to OpenGLCompatProfile.