- GLFW C library source is included and built automatically as part of the Go package. But you need to make sure you have dependencies of GLFW:
- On macOS, you need Xcode or Command Line Tools for Xcode (
xcode-select --install) for required headers and libraries. - On Ubuntu/Debian-like Linux distributions, you need
libgl1-mesa-devandxorg-devpackages. - On CentOS/Fedora-like Linux distributions, you need
libX11-devel libXcursor-devel libXrandr-devel libXinerama-devel mesa-libGL-devel libXi-develpackages. - See here for full details.
- On macOS, you need Xcode or Command Line Tools for Xcode (
- Go 1.4+ is required on Windows (otherwise you must use MinGW v4.8.1 exactly, see Go issue 8811).
go get -u github.com/go-gl/glfw/v3.2/glfw
package main
import (
"runtime"
"github.com/go-gl/glfw/v3.2/glfw"
)
func init() {
// This is needed to arrange that main() runs on main thread.
// See documentation for functions that are only allowed to be called from the main thread.
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()
}
}- Easy
go getinstallation. GLFW source code is now included in-repo and compiled in so you don't have to build GLFW on your own and distribute shared libraries. The revision of GLFW C library used is listed in GLFW_C_REVISION.txt file. - The error callback is now set internally. Functions return an error with corresponding code and description (do a type assertion to glfw3.Error for accessing the variables) if the error is recoverable. If not a panic will occur.
- Added function
Window.SetSizeLimits. - Added function
Window.SetAspectRatio. - Added function
Window.SetMonitor. - Added function
Window.Maximize. - Added function
Window.SetIcon. - Added function
Window.Focus. - Added function
GetKeyName. - Added function
VulkanSupported. - Added function
GetTimerValue. - Added function
GetTimerFrequency. - Added function
WaitEventsTimeout. - Added function
SetJoystickCallback. - Added window hint
Maximized. - Added hint
NoAPI. - Added hint
NativeContextAPI. - Added hint
EGLContextAPI.
- Added type
Cursor. - Added function
Window.SetDropCallback. - Added function
Window.SetCharModsCallback. - Added function
PostEmptyEvent. - Added function
CreateCursor. - Added function
CreateStandardCursor. - Added function
Cursor.Destroy. - Added function
Window.SetCursor. - Added function
Window.GetFrameSize. - Added window hint
Floating. - Added window hint
AutoIconify. - Added window hint
ContextReleaseBehavior. - Added window hint
DoubleBuffer. - Added hint value
AnyReleaseBehavior. - Added hint value
ReleaseBehaviorFlush. - Added hint value
ReleaseBehaviorNone. - Added hint value
DontCare.
Window.IconifyReturns an error.Window.RestoreReturns an error.InitReturns an error instead ofbool.GetJoystickAxesNo longer returns an error.GetJoystickButtonsNo longer returns an error.GetJoystickNameNo longer returns an error.GetMonitorsNo longer returns an error.GetPrimaryMonitorNo longer returns an error.Monitor.GetGammaRampNo longer returns an error.Monitor.GetVideoModeNo longer returns an error.Monitor.GetVideoModesNo longer returns an error.GetCurrentContextNo longer returns an error.Window.SetCharCallbackAcceptsruneinstead ofuint.- Added type
Error. - Removed
SetErrorCallback. - Removed error code
NotInitialized. - Removed error code
NoCurrentContext. - Removed error code
InvalidEnum. - Removed error code
InvalidValue. - Removed error code
OutOfMemory. - Removed error code
PlatformError. - Removed
KeyBracket. - Renamed
Window.SetCharacterCallbacktoWindow.SetCharCallback. - Renamed
Window.GetCursorPositiontoGetCursorPos. - Renamed
Window.SetCursorPositiontoSetCursorPos. - Renamed
CursorPositionCallbacktoCursorPosCallback. - Renamed
Window.SetCursorPositionCallbacktoSetCursorPosCallback. - Renamed
VideoModetoVidMode. - Renamed
Monitor.GetPositiontoMonitor.GetPos. - Renamed
Window.GetPositiontoWindow.GetPos. - Renamed
Window.SetPositiontoWindow.SetPos. - Renamed
Window.GetAttributetoWindow.GetAttrib. - Renamed
Window.SetPositionCallbacktoWindow.SetPosCallback. - Renamed
PositionCallbacktoPosCallback. - Ranamed
CursortoCursorMode. - Renamed
StickyKeystoStickyKeysMode. - Renamed
StickyMouseButtonstoStickyMouseButtonsMode. - Renamed
ApiUnavailabletoAPIUnavailable. - Renamed
ClientApitoClientAPI. - Renamed
OpenglForwardCompatibletoOpenGLForwardCompatible. - Renamed
OpenglDebugContexttoOpenGLDebugContext. - Renamed
OpenglProfiletoOpenGLProfile. - Renamed
SrgbCapabletoSRGBCapable. - Renamed
OpenglApitoOpenGLAPI. - Renamed
OpenglEsApitoOpenGLESAPI. - Renamed
OpenglAnyProfiletoOpenGLAnyProfile. - Renamed
OpenglCoreProfiletoOpenGLCoreProfile. - Renamed
OpenglCompatProfiletoOpenGLCompatProfile. - Renamed
KeyKp...toKeyKP....