Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type CompositeMode
- type CursorMode
- type Event
- type Filter
- type GamepadAttach
- type GamepadAxis
- type GamepadButton
- type GamepadButtonDown
- type GamepadButtonUp
- type GamepadDetach
- type Graphics
- type Image
- type Input
- type Key
- type KeyboardKeyCharacter
- type KeyboardKeyDown
- type KeyboardKeyUp
- type Modifier
- type MouseButton
- type MouseButtonDown
- type MouseButtonUp
- type MouseEnter
- type MouseLeave
- type MouseMove
- type MouseWheel
- type Operation
- type ReplacePixelsArgs
- type TouchBegin
- type TouchCancel
- type TouchEnd
- type TouchMove
- type UI
- type UIContext
- type VDirection
- type ViewSize
- type ViewUpdate
- type Window
Constants ¶
const GamepadButtonNum = 32
Variables ¶
var RegularTermination = errors.New("regular termination")
RegularTermination represents a regular termination. Run can return this error, and if this error is received, the game loop should be terminated as soon as possible.
Functions ¶
This section is empty.
Types ¶
type CompositeMode ¶
type CompositeMode int
const ( CompositeModeUnknown CompositeMode = iota - 1 CompositeModeSourceOver // This value must be 0 (= initial value) CompositeModeClear CompositeModeCopy CompositeModeDestination CompositeModeDestinationOver CompositeModeSourceIn CompositeModeDestinationIn CompositeModeSourceOut CompositeModeDestinationOut CompositeModeSourceAtop CompositeModeDestinationAtop CompositeModeXor CompositeModeLighter CompositeModeMax = CompositeModeLighter )
func (CompositeMode) Operations ¶
func (c CompositeMode) Operations() (src Operation, dst Operation)
type CursorMode ¶ added in v1.11.0
type CursorMode int
const ( CursorModeVisible CursorMode = 1 << iota CursorModeHidden CursorModeCaptured )
type GamepadAttach ¶
type GamepadAttach struct { // ID represents which gamepad caused the event. ID int // Axes represents the amount of axes the gamepad has. Axes int // Buttons represents the amount of buttons the gamepad has. Buttons int }
GamepadAttach happens when a new gamepad is attached.
type GamepadAxis ¶
type GamepadAxis struct { // ID represents which gamepad caused the event. ID int // Axis is the axis of the game pad that changed position. Axis int // Position is the position of the axis after the change. It varies between -1.0 and 1.0. Position float32 }
GamepadAxis is for event where an axis on a gamepad changes.
type GamepadButton ¶
type GamepadButton int
const ( GamepadButton0 GamepadButton = iota GamepadButton1 GamepadButton2 GamepadButton3 GamepadButton4 GamepadButton5 GamepadButton6 GamepadButton7 GamepadButton8 GamepadButton9 GamepadButton10 GamepadButton11 GamepadButton12 GamepadButton13 GamepadButton14 GamepadButton15 GamepadButton16 GamepadButton17 GamepadButton18 GamepadButton19 GamepadButton20 GamepadButton21 GamepadButton22 GamepadButton23 GamepadButton24 GamepadButton25 GamepadButton26 GamepadButton27 GamepadButton28 GamepadButton29 GamepadButton30 GamepadButton31 )
type GamepadButtonDown ¶
type GamepadButtonDown struct { // ID represents which gamepad caused the event. ID int // Button is the button that was pressed on the game pad. Button int // Pressure is the pressure that is applied to the gamepad button. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 }
GamepadButtonDown is a gamepad button press event.
type GamepadButtonUp ¶
type GamepadButtonUp struct { // ID represents which gamepad caused the event. ID int // Button is the button that was pressed on the game pad. Button int // Pressure is the pressure that is applied to the gamepad button. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 }
GamepadButtonUp is a gamepad button release event.
type GamepadDetach ¶
type GamepadDetach struct { // ID represents which gamepad caused the event. ID int }
GamepadDetach happens when a gamepad is detached.
type Graphics ¶
type Graphics interface { SetThread(thread *thread.Thread) Begin() End() SetTransparent(transparent bool) SetVertices(vertices []float32, indices []uint16) NewImage(width, height int) (Image, error) NewScreenFramebufferImage(width, height int) (Image, error) Reset() error Draw(indexLen int, indexOffset int, mode CompositeMode, colorM *affine.ColorM, filter Filter, address Address) error SetVsyncEnabled(enabled bool) VDirection() VDirection NeedsRestoring() bool IsGL() bool HasHighPrecisionFloat() bool MaxImageSize() int }
type Image ¶
type Image interface { Dispose() IsInvalidated() bool Pixels() ([]byte, error) SetAsDestination() SetAsSource() ReplacePixels(args []*ReplacePixelsArgs) }
type Input ¶
type Input interface { CursorPosition() (x, y int) GamepadSDLID(id int) string GamepadName(id int) string GamepadAxis(id int, axis int) float64 GamepadAxisNum(id int) int GamepadButtonNum(id int) int GamepadIDs() []int IsGamepadButtonPressed(id int, button GamepadButton) bool IsKeyPressed(key Key) bool IsMouseButtonPressed(button MouseButton) bool ResetForFrame() RuneBuffer() []rune TouchIDs() []int TouchPosition(id int) (x, y int) Wheel() (xoff, yoff float64) }
type Key ¶
type Key int
const ( Key0 Key = iota Key1 Key2 Key3 Key4 Key5 Key6 Key7 Key8 Key9 KeyA KeyB KeyC KeyD KeyE KeyF KeyG KeyH KeyI KeyJ KeyK KeyL KeyM KeyN KeyO KeyP KeyQ KeyR KeyS KeyT KeyU KeyV KeyW KeyX KeyY KeyZ KeyApostrophe KeyBackslash KeyBackspace KeyCapsLock KeyComma KeyDelete KeyDown KeyEnd KeyEnter KeyEqual KeyEscape KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyGraveAccent KeyHome KeyInsert KeyKP0 KeyKP1 KeyKP2 KeyKP3 KeyKP4 KeyKP5 KeyKP6 KeyKP7 KeyKP8 KeyKP9 KeyKPAdd KeyKPDecimal KeyKPDivide KeyKPEnter KeyKPEqual KeyKPMultiply KeyKPSubtract KeyLeft KeyLeftAlt KeyLeftBracket KeyLeftControl KeyLeftShift KeyMenu KeyMinus KeyNumLock KeyPageDown KeyPageUp KeyPause KeyPeriod KeyPrintScreen KeyRight KeyRightAlt KeyRightBracket KeyRightControl KeyRightShift KeyScrollLock KeySemicolon KeySlash KeySpace KeyTab KeyUp KeyReserved0 KeyReserved1 KeyReserved2 )
type KeyboardKeyCharacter ¶
type KeyboardKeyCharacter struct { // Key is the key code of the key typed. Key Key // Modifier is the logical-or value of the modifiers pressed together with the key. Modifier Modifier // Character is the character that was typed. Character rune }
KeyboardKeyCharacter is an event that occurs when a character is actually typed on the keyboard. This may be provided by an input method.
type KeyboardKeyDown ¶
type KeyboardKeyDown struct { // Key is the key code of the key pressed or released. Key Key // Modifier is the logical-or value of the modifiers pressed together with the key. Modifier Modifier }
KeyboardKeyDown is an event that occurs when a key is pressed on the keyboard.
type KeyboardKeyUp ¶
type KeyboardKeyUp struct { // Key is the key code of the key pressed or released. Key Key // Modifier is the logical-or value of the modifiers pressed together with the key. Modifier Modifier }
KeyboardKeyUp is an event that occurs when a key is released on the keyboard.
type MouseButton ¶
type MouseButton int
const ( MouseButtonLeft MouseButton = iota MouseButtonRight MouseButtonMiddle )
type MouseButtonDown ¶
type MouseButtonDown struct { // X is the X position of the mouse pointer. This value is expressed in device independent pixels. X float32 // Y is the Y position of the mouse pointer. This value is expressed in device independent pixels. Y float32 // Button is the button on the mouse that was pressed. TODO: this should change later from an int to an enumeration type. Button int // Pressure is the pressure applied on the mouse button. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 }
MouseButtonDown is a mouse button press event.
type MouseButtonUp ¶
type MouseButtonUp struct { // X is the X position of the mouse pointer. This value is expressed in device independent pixels. X float32 // Y is the Y position of the mouse pointer. This value is expressed in device independent pixels. Y float32 // Button is the button on the mouse that was pressed. TODO: this should change later from an int to an enumeration type. Button int // Pressure is the pressure applied on the mouse button. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 }
MouseButtonUp is a mouse button release event.
type MouseEnter ¶
type MouseEnter struct { // X is the X position of the mouse pointer. This value is expressed in device independent pixels. X float32 // Y is the Y position of the mouse pointer. This value is expressed in device independent pixels. Y float32 }
MouseEnter occurs when the mouse enters the view window.
type MouseLeave ¶
type MouseLeave struct { // X is the X position of the mouse pointer. This value is expressed in device independent pixels. X float32 // Y is the Y position of the mouse pointer. This value is expressed in device independent pixels. Y float32 }
MouseLeave occurs when the mouse leaves the view window.
type MouseMove ¶
type MouseMove struct { // X is the X position of the mouse pointer. This value is expressed in device independent pixels. X float32 // Y is the Y position of the mouse pointer. This value is expressed in device independent pixels. Y float32 // DeltaX is the change in X since the last MouseMove event. This value is expressed in device independent pixels. DeltaX float32 // DeltaY is the change in Y since the last MouseMove event. This value is expressed in device independent pixels. DeltaY float32 }
MouseMove is a mouse movement event.
type MouseWheel ¶
type MouseWheel struct { // X is the X position of the mouse wheel. This value is expressed in arbitrary units. It increases when the mouse wheel is scrolled downwards, and decreases when the mouse is scrolled upwards. X float32 // Y is the Y position of the mouse wheel. This value is expressed in arbitrary units. It increases when the mouse wheel is scrolled to the right, and decreases when the mouse is scrolled to the left. Y float32 // DeltaX is the change in X since the last MouseWheel event. This value is expressed in arbitrary units. It is positive when the mouse wheel is scrolled downwards, and negative when the mouse is scrolled upwards. DeltaX float32 // DeltaY is the change in Y since the last MouseWheel event. This value is expressed in arbitrary units. It is positive when the mouse wheel is scrolled to the right, and negative when the mouse is scrolled to the left. DeltaY float32 }
MouseWheel is a mouse wheel event.
type ReplacePixelsArgs ¶ added in v1.11.0
type TouchBegin ¶
type TouchBegin struct { // ID identifies the touch that caused the touch event. ID int // X is the X position of the touch. This value is expressed in device independent pixels. X float32 // Y is the Y position of the touch. This value is expressed in device independent pixels. Y float32 // DeltaX is the change in X since last touch event. This value is expressed in device independent pixels. DeltaX float32 // Deltay is the change in Y since last touch event. This value is expressed in device independent pixels. Deltay float32 // Pressure of applied touch. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 // Primary represents whether the touch event is the primary touch or not. If it is true, then it is a primary touch. If it is false then it is not. Primary bool }
TouchBegin occurs when a touch begins.
type TouchCancel ¶
type TouchCancel struct { // ID identifies the touch that caused the touch event. ID int }
TouchCancel occurs when a touch is canceled. This can happen in various situations, depending on the underlying platform, for example when the application loses focus.
type TouchEnd ¶
type TouchEnd struct { // ID identifies the touch that caused the touch event. ID int // X is the X position of the touch. This value is expressed in device independent pixels. X float32 // Y is the Y position of the touch. This value is expressed in device independent pixels. Y float32 // DeltaX is the change in X since last touch event. This value is expressed in device independent pixels. DeltaX float32 // Deltay is the change in Y since last touch event. This value is expressed in device independent pixels. Deltay float32 // Pressure of applied touch. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 // Primary represents whether the touch event is the primary touch or not. If it is true, then it is a primary touch. If it is false then it is not. Primary bool }
TouchEnd occurs when a touch ends.
type TouchMove ¶
type TouchMove struct { // ID identifies the touch that caused the touch event. ID int // X is the X position of the touch. This value is expressed in device independent pixels. X float32 // Y is the Y position of the touch. This value is expressed in device independent pixels. Y float32 // DeltaX is the change in X since last touch event. This value is expressed in device independent pixels. DeltaX float32 // Deltay is the change in Y since last touch event. This value is expressed in device independent pixels. Deltay float32 // Pressure of applied touch. It varies between 0.0 for not pressed, and 1.0 for completely pressed. Pressure float32 // Primary represents whether the touch event is the primary touch or not. If it is true, then it is a primary touch. If it is false then it is not. Primary bool }
TouchMove occurs when a touch moved, or in other words, is dragged.
type UI ¶
type UI interface { Run(context UIContext) error RunWithoutMainLoop(context UIContext) DeviceScaleFactor() float64 CursorMode() CursorMode IsFullscreen() bool IsFocused() bool IsRunnableOnUnfocused() bool IsVsyncEnabled() bool ScreenSizeInFullscreen() (int, int) IsScreenTransparent() bool SetCursorMode(mode CursorMode) SetFullscreen(fullscreen bool) SetRunnableOnUnfocused(runnableOnUnfocused bool) SetVsyncEnabled(enabled bool) SetScreenTransparent(transparent bool) Input() Input Window() Window Graphics() Graphics }
type ViewSize ¶
type ViewSize struct { // Width is the width of the view. This value is expressed in device independent pixels. Width int // Height is the height of the view. This value is expressed in device independent pixels. Height int }
ViewSize occurs when the size of the application's view port changes.
type ViewUpdate ¶
type ViewUpdate struct { }
ViewUpdate occurs when the application is ready to update the next frame on the view port.
type Window ¶ added in v1.11.0
type Window interface { IsDecorated() bool SetDecorated(decorated bool) IsResizable() bool SetResizable(resizable bool) Position() (int, int) SetPosition(x, y int) Size() (int, int) SetSize(width, height int) IsFloating() bool SetFloating(floating bool) Maximize() IsMaximized() bool Minimize() IsMinimized() bool SetIcon(iconImages []image.Image) SetTitle(title string) Restore() }