Documentation
¶
Overview ¶
glfw is a purego binding of GLFW 3.4.
Threading ¶
Most GLFW calls must run on the main thread. Init locks the calling OS thread via runtime.LockOSThread; keep event polling and window creation on that thread.
Handles and GC ¶
Window, Monitor, and Cursor are Go-owned wrappers around opaque C handles. Callbacks receive the same Go *Window / *Monitor values registered at create time. User data from SetUserPointer is stored on the Go wrapper as any; it is not written into GLFW's C user-pointer slot, so the GC can track it safely.
Callbacks use one stable C trampoline per callback kind. Set*Callback replaces the Go func and returns the previous one. Destroy and Terminate clear retained callbacks and handle maps.
Shared libraries and EGL (macOS) ¶
Init loads libglfw from system paths, Homebrew locations, the executable directory, or Contents/Frameworks. For EGL/OpenGL ES contexts, GLFW itself loads libEGL and libGLESv2 by leaf name. On macOS that requires packaging those dylibs where dyld can see them (typically Contents/Frameworks with an LC_RPATH of @executable_path/../Frameworks on the main binary). A Homebrew libglfw alone is not a viable way to ship EGL/ANGLE; see the README.
Index ¶
- Constants
- func DefaultWindowHints()
- func ExtensionSupported(extension string) bool
- func GamepadName(jid Joystick) string
- func GetJoystickAxes(jid Joystick) ([]float32, error)
- func GetJoystickButtons(jid Joystick) ([]byte, error)
- func GetJoystickHats(jid Joystick) ([]byte, error)
- func GetKeyName(key Key, scancode int32) string
- func GetKeyScancode(key Key) int32
- func GetProcAddress(procname string) unsafe.Pointer
- func GetRequiredInstanceExtensions() []string
- func GetTime() float64
- func GetTimerFrequency() uint64
- func GetTimerValue() uint64
- func GetVersion() (major, minor, rev int32)
- func GetVersionString() string
- func Init() error
- func JoystickGUID(jid Joystick) string
- func JoystickIsGamepad(jid Joystick) bool
- func JoystickName(jid Joystick) string
- func JoystickPresent(jid Joystick) bool
- func JoystickUserPointer(jid Joystick) any
- func PlatformSupported(platform PlatformID) bool
- func PollEvents()
- func PostEmptyEvent()
- func RawMouseMotionSupported() bool
- func SetJoystickUserPointer(jid Joystick, ptr any)
- func SetTime(time float64)
- func SwapInterval(interval int32)
- func Terminate()
- func UpdateGamepadMappings(str string) bool
- func VulkanSupported() bool
- func WaitEvents()
- func WaitEventsTimeout(timeout float64)
- func WindowHint(hint Hint, value int32)
- func WindowHintString(hint Hint, value string)
- type Action
- type CharFunc
- type CharModsFunc
- type Cursor
- type CursorEnterFunc
- type CursorPosFunc
- type DropFunc
- type ErrorCode
- type ErrorFunc
- type FramebufferSizeFunc
- type GamepadAxis
- type GamepadButton
- type GamepadState
- type GammaRamp
- type Hint
- type Image
- type InputMode
- type Joystick
- type JoystickFunc
- type JoystickHatState
- type Key
- type KeyFunc
- type ModifierKey
- type Monitor
- func (m *Monitor) ContentScale() (xscale, yscale float32)
- func (m *Monitor) GammaRamp() GammaRamp
- func (m *Monitor) Name() string
- func (m *Monitor) PhysicalSize() (wMM, hMM int32)
- func (m *Monitor) Pos() (x, y int32)
- func (m *Monitor) SetGamma(gamma float32)
- func (m *Monitor) SetGammaRamp(ramp *GammaRamp)
- func (m *Monitor) SetUserPointer(ptr any)
- func (m *Monitor) UserPointer() any
- func (m *Monitor) VideoMode() VidMode
- func (m *Monitor) VideoModes() []VidMode
- func (m *Monitor) Workarea() (x, y, w2, h int32)
- type MonitorFunc
- type MouseButton
- type MouseButtonFunc
- type PeripheralEvent
- type PlatformID
- type ScrollFunc
- type StandardCursor
- type VidMode
- type Window
- func (w *Window) ClipboardString() string
- func (w *Window) ContentScale() (xscale, yscale float32)
- func (w *Window) CursorPos() (x, y float64)
- func (w *Window) Destroy()
- func (w *Window) Focus()
- func (w *Window) FrameSize() (left, top, right, bottom int32)
- func (w *Window) FramebufferSize() (w2, h int32)
- func (w *Window) GetAttrib(attrib Hint) int32
- func (w *Window) GetInputMode(mode InputMode) int32
- func (w *Window) Hide()
- func (w *Window) Iconify()
- func (w *Window) Key(key Key) Action
- func (w *Window) MakeContextCurrent()
- func (w *Window) Maximize()
- func (w *Window) Monitor() *Monitor
- func (w *Window) MouseButton(button MouseButton) Action
- func (w *Window) Opacity() float32
- func (w *Window) Pos() (x, y int32)
- func (w *Window) RequestAttention()
- func (w *Window) Restore()
- func (w *Window) SetAspectRatio(numer, denom int32)
- func (w *Window) SetAttrib(attrib Hint, value int32)
- func (w *Window) SetCharCallback(cb CharFunc) CharFunc
- func (w *Window) SetCharModsCallback(cb CharModsFunc) CharModsFunc
- func (w *Window) SetClipboardString(str string)
- func (w *Window) SetCloseCallback(cb WindowCloseFunc) WindowCloseFunc
- func (w *Window) SetContentScaleCallback(cb WindowContentScaleFunc) WindowContentScaleFunc
- func (w *Window) SetCursor(cursor *Cursor)
- func (w *Window) SetCursorEnterCallback(cb CursorEnterFunc) CursorEnterFunc
- func (w *Window) SetCursorPos(x, y float64)
- func (w *Window) SetCursorPosCallback(cb CursorPosFunc) CursorPosFunc
- func (w *Window) SetDropCallback(cb DropFunc) DropFunc
- func (w *Window) SetFocusCallback(cb WindowFocusFunc) WindowFocusFunc
- func (w *Window) SetFramebufferSizeCallback(cb FramebufferSizeFunc) FramebufferSizeFunc
- func (w *Window) SetIcon(images []Image)
- func (w *Window) SetIconifyCallback(cb WindowIconifyFunc) WindowIconifyFunc
- func (w *Window) SetInputMode(mode InputMode, value int32)
- func (w *Window) SetKeyCallback(cb KeyFunc) KeyFunc
- func (w *Window) SetMaximizeCallback(cb WindowMaximizeFunc) WindowMaximizeFunc
- func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int32)
- func (w *Window) SetMouseButtonCallback(cb MouseButtonFunc) MouseButtonFunc
- func (w *Window) SetOpacity(opacity float32)
- func (w *Window) SetPos(x, y int32)
- func (w *Window) SetPosCallback(cb WindowPosFunc) WindowPosFunc
- func (w *Window) SetRefreshCallback(cb WindowRefreshFunc) WindowRefreshFunc
- func (w *Window) SetScrollCallback(cb ScrollFunc) ScrollFunc
- func (w *Window) SetShouldClose(v bool)
- func (w *Window) SetSize(width, height int32)
- func (w *Window) SetSizeCallback(cb WindowSizeFunc) WindowSizeFunc
- func (w *Window) SetSizeLimits(minW, minH, maxW, maxH int32)
- func (w *Window) SetTitle(title string)
- func (w *Window) SetUserPointer(ptr any)
- func (w *Window) ShouldClose() bool
- func (w *Window) Show()
- func (w *Window) Size() (w2, h int32)
- func (w *Window) SwapBuffers()
- func (w *Window) Title() string
- func (w *Window) UserPointer() any
- type WindowCloseFunc
- type WindowContentScaleFunc
- type WindowFocusFunc
- type WindowIconifyFunc
- type WindowMaximizeFunc
- type WindowPosFunc
- type WindowRefreshFunc
- type WindowSizeFunc
Constants ¶
const ( VersionMajor = 3 VersionMinor = 4 VersionRevision = 0 )
Version constants.
const ( CursorNormal int32 = 0x00034001 CursorHidden int32 = 0x00034002 CursorDisabled int32 = 0x00034003 CursorCaptured int32 = 0x00034004 )
Cursor mode values (use with InputMode CursorMode).
const ( True int32 = 1 False int32 = 0 NoAPI int32 = 0 OpenGLAPI int32 = 0x00030001 OpenGLESAPI int32 = 0x00030002 NoRobustness int32 = 0 NoResetNotification int32 = 0x00031001 LoseContextOnReset int32 = 0x00031002 OpenGLAnyProfile int32 = 0 OpenGLCoreProfile int32 = 0x00032001 OpenGLCompatProfile int32 = 0x00032002 AnyReleaseBehavior int32 = 0 ReleaseBehaviorFlush int32 = 0x00035001 ReleaseBehaviorNone int32 = 0x00035002 NativeContextAPI int32 = 0x00036001 EGLContextAPI int32 = 0x00036002 OSMesaContextAPI int32 = 0x00036003 AnglePlatformTypeNone int32 = 0x00037001 AnglePlatformTypeOpenGL int32 = 0x00037002 AnglePlatformTypeOpenGLES int32 = 0x00037003 AnglePlatformTypeD3D9 int32 = 0x00037004 AnglePlatformTypeD3D11 int32 = 0x00037005 AnglePlatformTypeVulkan int32 = 0x00037007 AnglePlatformTypeMetal int32 = 0x00037008 WaylandPreferLibdecor int32 = 0x00038001 WaylandDisableLibdecor int32 = 0x00038002 AnyPosition int32 = -0x80000000 DontCare int32 = -1 )
Variables ¶
This section is empty.
Functions ¶
func DefaultWindowHints ¶
func DefaultWindowHints()
DefaultWindowHints resets all window hints to their default values.
func ExtensionSupported ¶
ExtensionSupported reports whether the specified OpenGL or OpenGL ES extension is supported.
func GamepadName ¶
GamepadName returns the human-readable name of the gamepad mapped to the joystick.
func GetJoystickAxes ¶
GetJoystickAxes returns the values of all axes of the specified joystick.
func GetJoystickButtons ¶
GetJoystickButtons returns the state of all buttons of the specified joystick.
func GetJoystickHats ¶
GetJoystickHats returns the state of all hats of the specified joystick.
func GetKeyName ¶
GetKeyName returns the printable name of a key.
func GetKeyScancode ¶
GetKeyScancode returns the platform-specific scancode of a key.
func GetProcAddress ¶
GetProcAddress returns a raw OpenGL/OpenGL ES function pointer (not a Go func value). Pass it directly to your GL loader.
func GetRequiredInstanceExtensions ¶
func GetRequiredInstanceExtensions() []string
GetRequiredInstanceExtensions returns the Vulkan instance extensions required by GLFW.
func GetTimerFrequency ¶
func GetTimerFrequency() uint64
GetTimerFrequency returns the frequency of the raw timer in Hz.
func GetTimerValue ¶
func GetTimerValue() uint64
GetTimerValue returns the current value of the raw timer.
func GetVersion ¶
func GetVersion() (major, minor, rev int32)
GetVersion returns the compile-time major, minor, and revision of the GLFW library.
func GetVersionString ¶
func GetVersionString() string
GetVersionString returns a compile-time version string for the GLFW library.
func Init ¶
func Init() error
Init loads the platform GLFW shared library, registers trampolines, locks the OS thread, and initializes GLFW. Call Terminate before exit.
func JoystickGUID ¶
JoystickGUID returns the SDL-compatible GUID of the specified joystick.
func JoystickIsGamepad ¶
JoystickIsGamepad reports whether the joystick has a gamepad mapping.
func JoystickName ¶
JoystickName returns the name of the specified joystick.
func JoystickPresent ¶
JoystickPresent reports whether the specified joystick is present.
func JoystickUserPointer ¶
JoystickUserPointer returns the value previously passed to SetJoystickUserPointer.
func PlatformSupported ¶
func PlatformSupported(platform PlatformID) bool
PlatformSupported reports whether the specified platform is supported on this machine.
func PostEmptyEvent ¶
func PostEmptyEvent()
PostEmptyEvent posts an empty event from another thread to wake WaitEvents.
func RawMouseMotionSupported ¶
func RawMouseMotionSupported() bool
RawMouseMotionSupported reports whether raw mouse motion is supported.
func SetJoystickUserPointer ¶
SetJoystickUserPointer stores an arbitrary Go value for a joystick.
func SwapInterval ¶
func SwapInterval(interval int32)
SwapInterval sets the swap interval for the current OpenGL or OpenGL ES context.
func Terminate ¶
func Terminate()
Terminate shuts down GLFW and clears handle maps, user data, and global callbacks.
func UpdateGamepadMappings ¶
UpdateGamepadMappings adds or updates gamepad mappings from an ASCII string.
func VulkanSupported ¶
func VulkanSupported() bool
VulkanSupported reports whether the Vulkan loader and an ICD have been found.
func WaitEventsTimeout ¶
func WaitEventsTimeout(timeout float64)
WaitEventsTimeout waits with timeout for events and then processes them.
func WindowHint ¶
WindowHint sets a window creation hint. hint is a Hint name; value is typically True/False, an API enumerant (OpenGLAPI, OpenGLCoreProfile, …), DontCare, or a size.
When hint is ContextCreationAPI/EGLContextAPI or ClientAPI/OpenGLESAPI, this also tries to Dlopen EGL or GLESv2 from the same search paths as Init (system, Homebrew, Frameworks, sibling). On Windows that often helps GLFW's later LoadLibrary by basename. On macOS, GLFW still loads those libs by leaf name using dyld search rules; preload alone is not enough — see the README packaging notes.
func WindowHintString ¶
WindowHintString sets a string-valued window hint.
Types ¶
type CharModsFunc ¶
type CharModsFunc func(window *Window, codepoint uint32, mods ModifierKey)
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is a Go-owned wrapper around a GLFWcursor*.
func CreateCursor ¶
CreateCursor creates a cursor from an RGBA image. image pixels must remain reachable until the call returns (GLFW copies them).
func CreateStandardCursor ¶
func CreateStandardCursor(shape StandardCursor) *Cursor
CreateStandardCursor creates a cursor from a standard shape.
type CursorEnterFunc ¶
type CursorPosFunc ¶
type ErrorCode ¶
type ErrorCode int32
ErrorCode corresponds to an error code.
const ( NoError ErrorCode = 0 NotInitialized ErrorCode = 0x00010001 NoCurrentContext ErrorCode = 0x00010002 InvalidEnum ErrorCode = 0x00010003 InvalidValue ErrorCode = 0x00010004 OutOfMemory ErrorCode = 0x00010005 PlatformError ErrorCode = 0x00010008 NoWindowContext ErrorCode = 0x0001000A FeatureUnimplemented ErrorCode = 0x0001000D )
type ErrorFunc ¶
func SetErrorCallback ¶
SetErrorCallback sets the global error callback and returns the previous one. Pass nil to remove. The callback may be invoked on any thread GLFW uses.
type FramebufferSizeFunc ¶
type GamepadAxis ¶
type GamepadAxis int32
GamepadAxis corresponds to a gamepad axis.
const ( GamepadAxisLeftX GamepadAxis = 0 GamepadAxisLeftY GamepadAxis = 1 GamepadAxisRightX GamepadAxis = 2 GamepadAxisRightY GamepadAxis = 3 GamepadAxisLeftTrigger GamepadAxis = 4 GamepadAxisRightTrigger GamepadAxis = 5 GamepadAxisLast GamepadAxis = GamepadAxisRightTrigger )
type GamepadButton ¶
type GamepadButton int32
GamepadButton corresponds to a gamepad button.
const ( GamepadButtonA GamepadButton = 0 GamepadButtonB GamepadButton = 1 GamepadButtonX GamepadButton = 2 GamepadButtonY GamepadButton = 3 GamepadButtonLeftBumper GamepadButton = 4 GamepadButtonRightBumper GamepadButton = 5 GamepadButtonBack GamepadButton = 6 GamepadButtonStart GamepadButton = 7 GamepadButtonGuide GamepadButton = 8 GamepadButtonLeftThumb GamepadButton = 9 GamepadButtonRightThumb GamepadButton = 10 GamepadButtonDpadUp GamepadButton = 11 GamepadButtonDpadRight GamepadButton = 12 GamepadButtonDpadDown GamepadButton = 13 GamepadButtonDpadLeft GamepadButton = 14 GamepadButtonLast GamepadButton = GamepadButtonDpadLeft GamepadButtonCross GamepadButton = GamepadButtonA GamepadButtonCircle GamepadButton = GamepadButtonB GamepadButtonSquare GamepadButton = GamepadButtonX GamepadButtonTriangle GamepadButton = GamepadButtonY )
type GamepadState ¶
func GetGamepadState ¶
func GetGamepadState(jid Joystick) (*GamepadState, int32)
GetGamepadState returns the gamepad input state for the specified joystick.
type Hint ¶
type Hint int32
const ( Focused Hint = 0x00020001 Iconified Hint = 0x00020002 Resizable Hint = 0x00020003 Visible Hint = 0x00020004 Decorated Hint = 0x00020005 AutoIconify Hint = 0x00020006 Floating Hint = 0x00020007 Maximized Hint = 0x00020008 CenterCursor Hint = 0x00020009 TransparentFramebuffer Hint = 0x0002000A Hovered Hint = 0x0002000B FocusOnShow Hint = 0x0002000C MousePassthrough Hint = 0x0002000D PositionX Hint = 0x0002000E PositionY Hint = 0x0002000F RedBits Hint = 0x00021001 GreenBits Hint = 0x00021002 BlueBits Hint = 0x00021003 AlphaBits Hint = 0x00021004 DepthBits Hint = 0x00021005 StencilBits Hint = 0x00021006 AccumRedBits Hint = 0x00021007 AccumGreenBits Hint = 0x00021008 AccumBlueBits Hint = 0x00021009 AccumAlphaBits Hint = 0x0002100A AuxBuffers Hint = 0x0002100B Stereo Hint = 0x0002100C Samples Hint = 0x0002100D SRGBCapable Hint = 0x0002100E RefreshRate Hint = 0x0002100F Doublebuffer Hint = 0x00021010 ClientAPI Hint = 0x00022001 ContextVersionMajor Hint = 0x00022002 ContextVersionMinor Hint = 0x00022003 ContextRevision Hint = 0x00022004 ContextRobustness Hint = 0x00022005 OpenGLForwardCompat Hint = 0x00022006 ContextDebug Hint = 0x00022007 OpenGLDebugContext Hint = ContextDebug OpenGLProfile Hint = 0x00022008 ContextReleaseBehavior Hint = 0x00022009 ContextNoError Hint = 0x0002200A ContextCreationAPI Hint = 0x0002200B ScaleToMonitor Hint = 0x0002200C ScaleFramebuffer Hint = 0x0002200D CocoaRetinaFramebuffer Hint = 0x00023001 CocoaFrameName Hint = 0x00023002 CocoaGraphicsSwitching Hint = 0x00023003 X11ClassName Hint = 0x00024001 X11InstanceName Hint = 0x00024002 Win32KeyboardMenu Hint = 0x00025001 Win32ShowDefault Hint = 0x00025002 WaylandAppID Hint = 0x00026001 JoystickHatButtons Hint = 0x00050001 AnglePlatformType Hint = 0x00050002 Platform Hint = 0x00050003 CocoaChdirResources Hint = 0x00051001 CocoaMenubar Hint = 0x00051002 X11XcbVulkanSurface Hint = 0x00052001 WaylandLibdecor Hint = 0x00053001 )
type Joystick ¶
type Joystick int32
Joystick corresponds to a joystick ID.
const ( Joystick1 Joystick = 0 Joystick2 Joystick = 1 Joystick3 Joystick = 2 Joystick4 Joystick = 3 Joystick5 Joystick = 4 Joystick6 Joystick = 5 Joystick7 Joystick = 6 Joystick8 Joystick = 7 Joystick9 Joystick = 8 Joystick10 Joystick = 9 Joystick11 Joystick = 10 Joystick12 Joystick = 11 Joystick13 Joystick = 12 Joystick14 Joystick = 13 Joystick15 Joystick = 14 Joystick16 Joystick = 15 JoystickLast Joystick = Joystick16 )
type JoystickFunc ¶
type JoystickFunc func(jid Joystick, event PeripheralEvent)
func SetJoystickCallback ¶
func SetJoystickCallback(cb JoystickFunc) JoystickFunc
SetJoystickCallback sets the global joystick connection callback and returns the previous one.
type JoystickHatState ¶
type JoystickHatState int32
JoystickHatState corresponds to joystick hat states.
const ( HatCentered JoystickHatState = 0 HatUp JoystickHatState = 1 HatRight JoystickHatState = 2 HatDown JoystickHatState = 4 HatLeft JoystickHatState = 8 HatRightUp JoystickHatState = HatRight | HatUp HatRightDown JoystickHatState = HatRight | HatDown HatLeftUp JoystickHatState = HatLeft | HatUp HatLeftDown JoystickHatState = HatLeft | HatDown )
type Key ¶
type Key int32
Key corresponds to a keyboard key.
const ( KeyUnknown Key = -1 // Printable keys KeySpace Key = 32 KeyApostrophe Key = 39 // ' KeyComma Key = 44 // , KeyMinus Key = 45 // - KeyPeriod Key = 46 // . KeySlash Key = 47 // / Key0 Key = 48 Key1 Key = 49 Key2 Key = 50 Key3 Key = 51 Key4 Key = 52 Key5 Key = 53 Key6 Key = 54 Key7 Key = 55 Key8 Key = 56 Key9 Key = 57 KeySemicolon Key = 59 // ; KeyEqual Key = 61 // = KeyA Key = 65 KeyB Key = 66 KeyC Key = 67 KeyD Key = 68 KeyE Key = 69 KeyF Key = 70 KeyG Key = 71 KeyH Key = 72 KeyI Key = 73 KeyJ Key = 74 KeyK Key = 75 KeyL Key = 76 KeyM Key = 77 KeyN Key = 78 KeyO Key = 79 KeyP Key = 80 KeyQ Key = 81 KeyR Key = 82 KeyS Key = 83 KeyT Key = 84 KeyU Key = 85 KeyV Key = 86 KeyW Key = 87 KeyX Key = 88 KeyY Key = 89 KeyZ Key = 90 KeyLeftBracket Key = 91 // [ KeyBackslash Key = 92 // \ KeyRightBracket Key = 93 // ] KeyGraveAccent Key = 96 // ` KeyWorld_1 Key = 161 // non-US #1 KeyWorld_2 Key = 162 // non-US #2 // Function keys KeyEscape Key = 256 KeyEnter Key = 257 KeyTab Key = 258 KeyBackspace Key = 259 KeyInsert Key = 260 KeyDelete Key = 261 KeyRight Key = 262 KeyLeft Key = 263 KeyDown Key = 264 KeyUp Key = 265 KeyPageUp Key = 266 KeyPageDown Key = 267 KeyHome Key = 268 KeyEnd Key = 269 KeyCapsLock Key = 280 KeyScrollLock Key = 281 KeyNumLock Key = 282 KeyPrintScreen Key = 283 KeyPause Key = 284 KeyF1 Key = 290 KeyF2 Key = 291 KeyF3 Key = 292 KeyF4 Key = 293 KeyF5 Key = 294 KeyF6 Key = 295 KeyF7 Key = 296 KeyF8 Key = 297 KeyF9 Key = 298 KeyF10 Key = 299 KeyF11 Key = 300 KeyF12 Key = 301 KeyF13 Key = 302 KeyF14 Key = 303 KeyF15 Key = 304 KeyF16 Key = 305 KeyF17 Key = 306 KeyF18 Key = 307 KeyF19 Key = 308 KeyF20 Key = 309 KeyF21 Key = 310 KeyF22 Key = 311 KeyF23 Key = 312 KeyF24 Key = 313 KeyF25 Key = 314 KeyKP_0 Key = 320 KeyKP_1 Key = 321 KeyKP_2 Key = 322 KeyKP_3 Key = 323 KeyKP_4 Key = 324 KeyKP_5 Key = 325 KeyKP_6 Key = 326 KeyKP_7 Key = 327 KeyKP_8 Key = 328 KeyKP_9 Key = 329 KeyKP_Decimal Key = 330 KeyKP_Divide Key = 331 KeyKP_Multiply Key = 332 KeyKP_Subtract Key = 333 KeyKP_Add Key = 334 KeyKP_Enter Key = 335 KeyKP_Equal Key = 336 KeyLeft_Shift Key = 340 KeyLeft_Control Key = 341 KeyLeft_Alt Key = 342 KeyLeft_Super Key = 343 KeyRight_Shift Key = 344 KeyRight_Control Key = 345 KeyRight_Alt Key = 346 KeyRight_Super Key = 347 KeyMenu Key = 348 KeyLast Key = KeyMenu )
type KeyFunc ¶
type KeyFunc func(window *Window, key Key, scancode int32, action Action, mods ModifierKey)
type ModifierKey ¶
type ModifierKey int32
ModifierKey corresponds to a modifier key.
const ( ModShift ModifierKey = 0x0001 ModControl ModifierKey = 0x0002 ModAlt ModifierKey = 0x0004 ModSuper ModifierKey = 0x0008 ModCapsLock ModifierKey = 0x0010 ModNumLock ModifierKey = 0x0020 )
type Monitor ¶
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is a Go-owned wrapper around a GLFWmonitor*. Use SetUserPointer to attach Go values; they are not stored in C.
func GetMonitors ¶
GetMonitors returns the currently connected monitors.
func GetPrimaryMonitor ¶
func GetPrimaryMonitor() *Monitor
GetPrimaryMonitor returns the primary monitor.
func (*Monitor) ContentScale ¶
ContentScale returns the content scale of the monitor.
func (*Monitor) PhysicalSize ¶
PhysicalSize returns the physical size of the monitor in millimetres.
func (*Monitor) SetGamma ¶
SetGamma generates a gamma ramp from the specified exponent and applies it.
func (*Monitor) SetGammaRamp ¶
SetGammaRamp sets the current gamma ramp of the monitor.
func (*Monitor) SetUserPointer ¶
SetUserPointer stores an arbitrary Go value on this monitor (Go-side only).
func (*Monitor) UserPointer ¶
UserPointer returns the value previously passed to SetUserPointer.
func (*Monitor) VideoModes ¶
VideoModes returns all video modes supported by the monitor.
type MonitorFunc ¶
type MonitorFunc func(monitor *Monitor, event PeripheralEvent)
func SetMonitorCallback ¶
func SetMonitorCallback(cb MonitorFunc) MonitorFunc
SetMonitorCallback sets the global monitor connection callback and returns the previous one.
type MouseButton ¶
type MouseButton int32
MouseButton corresponds to a mouse button.
const ( MouseButton1 MouseButton = 0 MouseButton2 MouseButton = 1 MouseButton3 MouseButton = 2 MouseButton4 MouseButton = 3 MouseButton5 MouseButton = 4 MouseButton6 MouseButton = 5 MouseButton7 MouseButton = 6 MouseButton8 MouseButton = 7 MouseButtonLast MouseButton = MouseButton8 MouseButtonLeft MouseButton = MouseButton1 MouseButtonRight MouseButton = MouseButton2 MouseButtonMiddle MouseButton = MouseButton3 )
type MouseButtonFunc ¶
type MouseButtonFunc func(window *Window, button MouseButton, action Action, mods ModifierKey)
type PeripheralEvent ¶
type PeripheralEvent int32
PeripheralEvent corresponds to a monitor or joystick connection event.
const ( Connected PeripheralEvent = 0x00040001 Disconnected PeripheralEvent = 0x00040002 )
type PlatformID ¶
type PlatformID int32
PlatformID corresponds to a platform returned by GetPlatform.
const ( AnyPlatform PlatformID = 0x00060000 PlatformWin32 PlatformID = 0x00060001 PlatformCocoa PlatformID = 0x00060002 PlatformWayland PlatformID = 0x00060003 PlatformX11 PlatformID = 0x00060004 PlatformNull PlatformID = 0x00060005 )
func GetPlatform ¶
func GetPlatform() PlatformID
GetPlatform returns the currently selected platform.
type ScrollFunc ¶
type StandardCursor ¶
type StandardCursor int32
StandardCursor corresponds to a standard cursor shape.
const ( ArrowCursor StandardCursor = 0x00036001 IbeamCursor StandardCursor = 0x00036002 CrosshairCursor StandardCursor = 0x00036003 PointingHandCursor StandardCursor = 0x00036004 ResizeEWCursor StandardCursor = 0x00036005 ResizeNSCursor StandardCursor = 0x00036006 ResizeNWSECursor StandardCursor = 0x00036007 ResizeNESWCursor StandardCursor = 0x00036008 ResizeAllCursor StandardCursor = 0x00036009 NotAllowedCursor StandardCursor = 0x0003600A HResizeCursor StandardCursor = ResizeEWCursor VResizeCursor StandardCursor = ResizeNSCursor HandCursor StandardCursor = PointingHandCursor )
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is a Go-owned wrapper around a GLFWwindow*. Callbacks installed with Set*Callback receive this same *Window. Use SetUserPointer to attach Go values; they are not stored in C.
func CreateWindow ¶
CreateWindow creates a window and OpenGL/Vulkan-capable context (per hints). The returned *Window is a Go wrapper registered for callbacks; call Destroy when done. Pass nil monitor for windowed mode and nil share for no context sharing.
func CurrentContext ¶
func CurrentContext() *Window
CurrentContext returns the window whose OpenGL or OpenGL ES context is current.
func (*Window) ClipboardString ¶
ClipboardString returns the contents of the system clipboard.
func (*Window) ContentScale ¶
ContentScale returns the content scale of the window.
func (*Window) CursorPos ¶
CursorPos returns the position of the cursor relative to the content area.
func (*Window) Destroy ¶
func (w *Window) Destroy()
Destroy destroys the window, clears its callbacks and user data, and unregisters it from the handle map. The Window must not be used afterward.
func (*Window) Focus ¶
func (w *Window) Focus()
Focus brings the window to front and sets input focus.
func (*Window) FramebufferSize ¶
FramebufferSize returns the size of the framebuffer.
func (*Window) GetInputMode ¶
GetInputMode returns the value of an input option for the window.
func (*Window) MakeContextCurrent ¶
func (w *Window) MakeContextCurrent()
MakeContextCurrent makes the window's OpenGL or OpenGL ES context current.
func (*Window) MouseButton ¶
func (w *Window) MouseButton(button MouseButton) Action
MouseButton returns the last reported state of a mouse button.
func (*Window) RequestAttention ¶
func (w *Window) RequestAttention()
RequestAttention requests user attention to the window.
func (*Window) Restore ¶
func (w *Window) Restore()
Restore restores the window if it was iconified or maximized.
func (*Window) SetAspectRatio ¶
SetAspectRatio sets the required aspect ratio of the content area.
func (*Window) SetCharCallback ¶
SetCharCallback sets the Unicode character callback and returns the previous one.
func (*Window) SetCharModsCallback ¶
func (w *Window) SetCharModsCallback(cb CharModsFunc) CharModsFunc
SetCharModsCallback sets the character-with-modifiers callback and returns the previous one.
func (*Window) SetClipboardString ¶
SetClipboardString sets the system clipboard to the specified string.
func (*Window) SetCloseCallback ¶
func (w *Window) SetCloseCallback(cb WindowCloseFunc) WindowCloseFunc
SetCloseCallback sets the close callback and returns the previous one.
func (*Window) SetContentScaleCallback ¶
func (w *Window) SetContentScaleCallback(cb WindowContentScaleFunc) WindowContentScaleFunc
SetContentScaleCallback sets the content scale callback and returns the previous one.
func (*Window) SetCursor ¶
SetCursor sets the cursor image used when the cursor is over the content area. Pass nil to restore the default arrow cursor.
func (*Window) SetCursorEnterCallback ¶
func (w *Window) SetCursorEnterCallback(cb CursorEnterFunc) CursorEnterFunc
SetCursorEnterCallback sets the cursor enter/leave callback and returns the previous one.
func (*Window) SetCursorPos ¶
SetCursorPos sets the position of the cursor relative to the content area.
func (*Window) SetCursorPosCallback ¶
func (w *Window) SetCursorPosCallback(cb CursorPosFunc) CursorPosFunc
SetCursorPosCallback sets the cursor position callback and returns the previous one.
func (*Window) SetDropCallback ¶
SetDropCallback sets the path drop callback and returns the previous one.
func (*Window) SetFocusCallback ¶
func (w *Window) SetFocusCallback(cb WindowFocusFunc) WindowFocusFunc
SetFocusCallback sets the focus callback and returns the previous one.
func (*Window) SetFramebufferSizeCallback ¶
func (w *Window) SetFramebufferSizeCallback(cb FramebufferSizeFunc) FramebufferSizeFunc
SetFramebufferSizeCallback sets the framebuffer size callback and returns the previous one.
func (*Window) SetIconifyCallback ¶
func (w *Window) SetIconifyCallback(cb WindowIconifyFunc) WindowIconifyFunc
SetIconifyCallback sets the iconify callback and returns the previous one.
func (*Window) SetInputMode ¶
SetInputMode sets an input option for the window.
func (*Window) SetKeyCallback ¶
SetKeyCallback sets the key callback and returns the previous one.
func (*Window) SetMaximizeCallback ¶
func (w *Window) SetMaximizeCallback(cb WindowMaximizeFunc) WindowMaximizeFunc
SetMaximizeCallback sets the maximize callback and returns the previous one.
func (*Window) SetMonitor ¶
SetMonitor sets the monitor and video mode for fullscreen or windowed mode. Pass nil monitor to switch back to windowed mode.
func (*Window) SetMouseButtonCallback ¶
func (w *Window) SetMouseButtonCallback(cb MouseButtonFunc) MouseButtonFunc
SetMouseButtonCallback sets the mouse button callback and returns the previous one.
func (*Window) SetOpacity ¶
SetOpacity sets the opacity of the window.
func (*Window) SetPosCallback ¶
func (w *Window) SetPosCallback(cb WindowPosFunc) WindowPosFunc
SetPosCallback sets the window position callback and returns the previous one. Pass nil to remove. All Set*Callback methods on Window share this replace semantics.
func (*Window) SetRefreshCallback ¶
func (w *Window) SetRefreshCallback(cb WindowRefreshFunc) WindowRefreshFunc
SetRefreshCallback sets the refresh callback and returns the previous one.
func (*Window) SetScrollCallback ¶
func (w *Window) SetScrollCallback(cb ScrollFunc) ScrollFunc
SetScrollCallback sets the scroll callback and returns the previous one.
func (*Window) SetShouldClose ¶
SetShouldClose sets whether the window should be closed.
func (*Window) SetSizeCallback ¶
func (w *Window) SetSizeCallback(cb WindowSizeFunc) WindowSizeFunc
SetSizeCallback sets the window size callback and returns the previous one.
func (*Window) SetSizeLimits ¶
SetSizeLimits sets the minimum and maximum size limits of the content area.
func (*Window) SetUserPointer ¶
SetUserPointer stores an arbitrary Go value on this window. Unlike glfwSetWindowUserPointer, the value is kept only on the Go wrapper so the garbage collector can track it. Pass nil to clear.
func (*Window) ShouldClose ¶
ShouldClose reports whether the window has been requested to close.
func (*Window) SwapBuffers ¶
func (w *Window) SwapBuffers()
SwapBuffers swaps the front and back buffers of the window.
func (*Window) UserPointer ¶
UserPointer returns the value previously passed to SetUserPointer.
type WindowCloseFunc ¶
type WindowCloseFunc func(window *Window)
type WindowContentScaleFunc ¶
type WindowFocusFunc ¶
type WindowIconifyFunc ¶
type WindowMaximizeFunc ¶
type WindowPosFunc ¶
type WindowRefreshFunc ¶
type WindowRefreshFunc func(window *Window)