Documentation ¶
Overview ¶
Package glfw experimentally provides a glfw-like API with desktop (via glfw) and browser (via HTML5 canvas) backends.
It is used for creating a GL context and receiving events.
Note: This package is currently in development. The API is incomplete and may change.
Index ¶
- Constants
- func DefaultWindowHints()
- func DetachCurrentContext()
- func Init(cw ContextWatcher) error
- func Open(name string) (io.ReadCloser, error)
- func PollEvents()
- func PostEmptyEvent()
- func SwapInterval(interval int)
- func Terminate()
- func WaitEvents()
- func WindowHint(target Hint, hint int)
- type Action
- type CharCallback
- type CharModsCallback
- type CloseCallback
- type ContextWatcher
- type CursorEnterCallback
- type CursorPosCallback
- type DropCallback
- type FocusCallback
- type FramebufferSizeCallback
- type Hint
- type IconifyCallback
- type InputMode
- type Key
- type KeyCallback
- type ModifierKey
- type Monitor
- type MouseButton
- type MouseButtonCallback
- type MouseMovementCallback
- type PosCallback
- type RefreshCallback
- type ScrollCallback
- type SizeCallback
- type VidMode
- type Window
- func (w *Window) GetInputMode(mode InputMode) int
- func (w *Window) GetKey(key Key) Action
- func (w *Window) GetMouseButton(button MouseButton) Action
- func (w *Window) MakeContextCurrent()
- func (w *Window) SetCharCallback(cbfun CharCallback) (previous CharCallback)
- func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback)
- func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback)
- func (w *Window) SetCursorEnterCallback(cbfun CursorEnterCallback) (previous CursorEnterCallback)
- func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback)
- func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback)
- func (w *Window) SetFocusCallback(cbfun FocusCallback) (previous FocusCallback)
- func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback)
- func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCallback)
- func (w *Window) SetInputMode(mode InputMode, value int)
- func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback)
- func (w *Window) SetMouseButtonCallback(cbfun MouseButtonCallback) (previous MouseButtonCallback)
- func (w *Window) SetMouseMovementCallback(cbfun MouseMovementCallback) (previous MouseMovementCallback)
- func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback)
- func (w *Window) SetRefreshCallback(cbfun RefreshCallback) (previous RefreshCallback)
- func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback)
- func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback)
Constants ¶
const ( KeySpace = Key(glfw.KeySpace) KeyApostrophe = Key(glfw.KeyApostrophe) KeyComma = Key(glfw.KeyComma) KeyMinus = Key(glfw.KeyMinus) KeyPeriod = Key(glfw.KeyPeriod) KeySlash = Key(glfw.KeySlash) Key0 = Key(glfw.Key0) Key1 = Key(glfw.Key1) Key2 = Key(glfw.Key2) Key3 = Key(glfw.Key3) Key4 = Key(glfw.Key4) Key5 = Key(glfw.Key5) Key6 = Key(glfw.Key6) Key7 = Key(glfw.Key7) Key8 = Key(glfw.Key8) Key9 = Key(glfw.Key9) KeySemicolon = Key(glfw.KeySemicolon) KeyEqual = Key(glfw.KeyEqual) KeyA = Key(glfw.KeyA) KeyB = Key(glfw.KeyB) KeyC = Key(glfw.KeyC) KeyD = Key(glfw.KeyD) KeyE = Key(glfw.KeyE) KeyF = Key(glfw.KeyF) KeyG = Key(glfw.KeyG) KeyH = Key(glfw.KeyH) KeyI = Key(glfw.KeyI) KeyJ = Key(glfw.KeyJ) KeyK = Key(glfw.KeyK) KeyL = Key(glfw.KeyL) KeyM = Key(glfw.KeyM) KeyN = Key(glfw.KeyN) KeyO = Key(glfw.KeyO) KeyP = Key(glfw.KeyP) KeyQ = Key(glfw.KeyQ) KeyR = Key(glfw.KeyR) KeyS = Key(glfw.KeyS) KeyT = Key(glfw.KeyT) KeyU = Key(glfw.KeyU) KeyV = Key(glfw.KeyV) KeyW = Key(glfw.KeyW) KeyX = Key(glfw.KeyX) KeyY = Key(glfw.KeyY) KeyZ = Key(glfw.KeyZ) KeyLeftBracket = Key(glfw.KeyLeftBracket) KeyBackslash = Key(glfw.KeyBackslash) KeyRightBracket = Key(glfw.KeyRightBracket) KeyGraveAccent = Key(glfw.KeyGraveAccent) KeyWorld1 = Key(glfw.KeyWorld1) KeyWorld2 = Key(glfw.KeyWorld2) KeyEscape = Key(glfw.KeyEscape) KeyEnter = Key(glfw.KeyEnter) KeyTab = Key(glfw.KeyTab) KeyBackspace = Key(glfw.KeyBackspace) KeyInsert = Key(glfw.KeyInsert) KeyDelete = Key(glfw.KeyDelete) KeyRight = Key(glfw.KeyRight) KeyLeft = Key(glfw.KeyLeft) KeyDown = Key(glfw.KeyDown) KeyUp = Key(glfw.KeyUp) KeyPageUp = Key(glfw.KeyPageUp) KeyPageDown = Key(glfw.KeyPageDown) KeyHome = Key(glfw.KeyHome) KeyEnd = Key(glfw.KeyEnd) KeyCapsLock = Key(glfw.KeyCapsLock) KeyScrollLock = Key(glfw.KeyScrollLock) KeyNumLock = Key(glfw.KeyNumLock) KeyPrintScreen = Key(glfw.KeyPrintScreen) KeyPause = Key(glfw.KeyPause) KeyF1 = Key(glfw.KeyF1) KeyF2 = Key(glfw.KeyF2) KeyF3 = Key(glfw.KeyF3) KeyF4 = Key(glfw.KeyF4) KeyF5 = Key(glfw.KeyF5) KeyF6 = Key(glfw.KeyF6) KeyF7 = Key(glfw.KeyF7) KeyF8 = Key(glfw.KeyF8) KeyF9 = Key(glfw.KeyF9) KeyF10 = Key(glfw.KeyF10) KeyF11 = Key(glfw.KeyF11) KeyF12 = Key(glfw.KeyF12) KeyF13 = Key(glfw.KeyF13) KeyF14 = Key(glfw.KeyF14) KeyF15 = Key(glfw.KeyF15) KeyF16 = Key(glfw.KeyF16) KeyF17 = Key(glfw.KeyF17) KeyF18 = Key(glfw.KeyF18) KeyF19 = Key(glfw.KeyF19) KeyF20 = Key(glfw.KeyF20) KeyF21 = Key(glfw.KeyF21) KeyF22 = Key(glfw.KeyF22) KeyF23 = Key(glfw.KeyF23) KeyF24 = Key(glfw.KeyF24) KeyF25 = Key(glfw.KeyF25) KeyKP0 = Key(glfw.KeyKP0) KeyKP1 = Key(glfw.KeyKP1) KeyKP2 = Key(glfw.KeyKP2) KeyKP3 = Key(glfw.KeyKP3) KeyKP4 = Key(glfw.KeyKP4) KeyKP5 = Key(glfw.KeyKP5) KeyKP6 = Key(glfw.KeyKP6) KeyKP7 = Key(glfw.KeyKP7) KeyKP8 = Key(glfw.KeyKP8) KeyKP9 = Key(glfw.KeyKP9) KeyKPDecimal = Key(glfw.KeyKPDecimal) KeyKPDivide = Key(glfw.KeyKPDivide) KeyKPMultiply = Key(glfw.KeyKPMultiply) KeyKPSubtract = Key(glfw.KeyKPSubtract) KeyKPAdd = Key(glfw.KeyKPAdd) KeyKPEnter = Key(glfw.KeyKPEnter) KeyKPEqual = Key(glfw.KeyKPEqual) KeyLeftShift = Key(glfw.KeyLeftShift) KeyLeftControl = Key(glfw.KeyLeftControl) KeyLeftAlt = Key(glfw.KeyLeftAlt) KeyLeftSuper = Key(glfw.KeyLeftSuper) KeyRightShift = Key(glfw.KeyRightShift) KeyRightControl = Key(glfw.KeyRightControl) KeyRightAlt = Key(glfw.KeyRightAlt) KeyRightSuper = Key(glfw.KeyRightSuper) KeyMenu = Key(glfw.KeyMenu) )
const ( MouseButton1 = MouseButton(glfw.MouseButton1) MouseButton2 = MouseButton(glfw.MouseButton2) MouseButton3 = MouseButton(glfw.MouseButton3) MouseButtonLeft = MouseButton(glfw.MouseButtonLeft) MouseButtonRight = MouseButton(glfw.MouseButtonRight) MouseButtonMiddle = MouseButton(glfw.MouseButtonMiddle) )
const ( Release = Action(glfw.Release) Press = Action(glfw.Press) Repeat = Action(glfw.Repeat) )
const ( CursorMode = InputMode(glfw.CursorMode) StickyKeysMode = InputMode(glfw.StickyKeysMode) StickyMouseButtonsMode = InputMode(glfw.StickyMouseButtonsMode) )
const ( CursorNormal = int(glfw.CursorNormal) CursorHidden = int(glfw.CursorHidden) CursorDisabled = int(glfw.CursorDisabled) )
const ( ModShift = ModifierKey(glfw.ModShift) ModControl = ModifierKey(glfw.ModControl) ModAlt = ModifierKey(glfw.ModAlt) ModSuper = ModifierKey(glfw.ModSuper) )
const ( ClientAPI = Hint(glfw.ClientAPI) AlphaBits = Hint(glfw.AlphaBits) DepthBits = Hint(glfw.DepthBits) StencilBits = Hint(glfw.StencilBits) Samples = Hint(glfw.Samples) Resizable = Hint(glfw.Resizable) // These hints used for WebGL contexts, ignored on desktop. PremultipliedAlpha = noopHint PreserveDrawingBuffer PreferLowPowerToHighPerformance FailIfMajorPerformanceCaveat )
const (
NoAPI int = glfw.NoAPI
)
Variables ¶
This section is empty.
Functions ¶
func DefaultWindowHints ¶
func DefaultWindowHints()
func DetachCurrentContext ¶
func DetachCurrentContext()
func Init ¶
func Init(cw ContextWatcher) error
Init initializes the library.
A valid ContextWatcher must be provided. It gets notified when context becomes current or detached. It should be provided by the GL bindings you are using, so you can do glfw.Init(gl.ContextWatcher).
func Open ¶
func Open(name string) (io.ReadCloser, error)
Open opens a named asset. It's the caller's responsibility to close it when done.
For now, assets are read directly from the current working directory.
func PollEvents ¶
func PollEvents()
func PostEmptyEvent ¶
func PostEmptyEvent()
func SwapInterval ¶
func SwapInterval(interval int)
func WaitEvents ¶
func WaitEvents()
func WindowHint ¶
Types ¶
type CharCallback ¶
type CharModsCallback ¶
type CharModsCallback func(w *Window, char rune, mods ModifierKey)
type CloseCallback ¶
type CloseCallback func(w *Window)
type ContextWatcher ¶
type ContextWatcher interface { // OnMakeCurrent is called after a context is made current. // context is is a platform-specific representation of the context, or nil if unavailable. OnMakeCurrent(context interface{}) // OnDetach is called after the current context is detached. OnDetach() }
ContextWatcher is a general mechanism for being notified when context is made current or detached.
type CursorEnterCallback ¶
type CursorPosCallback ¶
type DropCallback ¶
type FocusCallback ¶
type FramebufferSizeCallback ¶
type IconifyCallback ¶
type KeyCallback ¶
type KeyCallback func(w *Window, key Key, scancode int, action Action, mods ModifierKey)
type ModifierKey ¶
type ModifierKey int
type Monitor ¶
func GetPrimaryMonitor ¶
func GetPrimaryMonitor() *Monitor
type MouseButton ¶
type MouseButton glfw.MouseButton
type MouseButtonCallback ¶
type MouseButtonCallback func(w *Window, button MouseButton, action Action, mods ModifierKey)
type MouseMovementCallback ¶
type PosCallback ¶
type RefreshCallback ¶
type RefreshCallback func(w *Window)
type ScrollCallback ¶
type SizeCallback ¶
type VidMode ¶
type VidMode struct { Width int // The width, in pixels, of the video mode. Height int // The height, in pixels, of the video mode. RedBits int // The bit depth of the red channel of the video mode. GreenBits int // The bit depth of the green channel of the video mode. BlueBits int // The bit depth of the blue channel of the video mode. RefreshRate int // The refresh rate, in Hz, of the video mode. }
VidMode describes a single video mode.
type Window ¶
func CreateWindow ¶
func (*Window) GetInputMode ¶
func (*Window) GetMouseButton ¶
func (w *Window) GetMouseButton(button MouseButton) Action
func (*Window) MakeContextCurrent ¶
func (w *Window) MakeContextCurrent()
func (*Window) SetCharCallback ¶
func (w *Window) SetCharCallback(cbfun CharCallback) (previous CharCallback)
func (*Window) SetCharModsCallback ¶
func (w *Window) SetCharModsCallback(cbfun CharModsCallback) (previous CharModsCallback)
func (*Window) SetCloseCallback ¶
func (w *Window) SetCloseCallback(cbfun CloseCallback) (previous CloseCallback)
func (*Window) SetCursorEnterCallback ¶
func (w *Window) SetCursorEnterCallback(cbfun CursorEnterCallback) (previous CursorEnterCallback)
func (*Window) SetCursorPosCallback ¶
func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback)
func (*Window) SetDropCallback ¶
func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback)
func (*Window) SetFocusCallback ¶
func (w *Window) SetFocusCallback(cbfun FocusCallback) (previous FocusCallback)
func (*Window) SetFramebufferSizeCallback ¶
func (w *Window) SetFramebufferSizeCallback(cbfun FramebufferSizeCallback) (previous FramebufferSizeCallback)
func (*Window) SetIconifyCallback ¶
func (w *Window) SetIconifyCallback(cbfun IconifyCallback) (previous IconifyCallback)
func (*Window) SetInputMode ¶
func (*Window) SetKeyCallback ¶
func (w *Window) SetKeyCallback(cbfun KeyCallback) (previous KeyCallback)
func (*Window) SetMouseButtonCallback ¶
func (w *Window) SetMouseButtonCallback(cbfun MouseButtonCallback) (previous MouseButtonCallback)
func (*Window) SetMouseMovementCallback ¶
func (w *Window) SetMouseMovementCallback(cbfun MouseMovementCallback) (previous MouseMovementCallback)
TODO: For now, this overrides SetCursorPosCallback; should support both.
func (*Window) SetPosCallback ¶
func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback)
func (*Window) SetRefreshCallback ¶
func (w *Window) SetRefreshCallback(cbfun RefreshCallback) (previous RefreshCallback)
func (*Window) SetScrollCallback ¶
func (w *Window) SetScrollCallback(cbfun ScrollCallback) (previous ScrollCallback)
func (*Window) SetSizeCallback ¶
func (w *Window) SetSizeCallback(cbfun SizeCallback) (previous SizeCallback)