Documentation ¶
Index ¶
- Constants
- Variables
- type Address
- type ColorM
- type CompositeMode
- type CursorMode
- type CursorShape
- type Event
- type FPSMode
- type Filter
- type GamepadAttach
- type GamepadAxis
- type GamepadButton
- type GamepadButtonDown
- type GamepadButtonUp
- type GamepadDetach
- type GamepadID
- type Graphics
- type Image
- type ImageID
- 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 Region
- type ReplacePixelsArgs
- type Shader
- type ShaderID
- type StandardGamepadAxis
- type StandardGamepadButton
- type TouchBegin
- type TouchCancel
- type TouchEnd
- type TouchID
- type TouchMove
- type UI
- type UIContext
- type ViewSize
- type ViewUpdate
- type Window
- type YDirection
Constants ¶
const ( InvalidImageID = 0 InvalidShaderID = 0 )
const GamepadButtonNum = 32
Variables ¶
var GraphicsNotReady = errors.New("graphics not ready")
GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.
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 CompositeModeMultiply CompositeModeMax = CompositeModeMultiply )
func (CompositeMode) Operations ¶
func (c CompositeMode) Operations() (src Operation, dst Operation)
type CursorMode ¶
type CursorMode int
const ( CursorModeVisible CursorMode = iota CursorModeHidden CursorModeCaptured )
type CursorShape ¶ added in v2.1.0
type CursorShape int
const ( CursorShapeDefault CursorShape = iota CursorShapeText CursorShapeCrosshair CursorShapePointer CursorShapeEWResize CursorShapeNSResize )
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 { Begin() End() SetTransparent(transparent bool) SetVertices(vertices []float32, indices []uint16) NewImage(width, height int) (Image, error) NewScreenFramebufferImage(width, height int) (Image, error) Initialize() error SetVsyncEnabled(enabled bool) SetFullscreen(fullscreen bool) FramebufferYDirection() YDirection NeedsRestoring() bool NeedsClearingScreen() bool IsGL() bool HasHighPrecisionFloat() bool MaxImageSize() int NewShader(program *shaderir.Program) (Shader, error) // DrawTriangles draws an image onto another image with the given parameters. // // uniforms represents a colletion of uniform variables. The values must be one of these types: // // * float32 // * []float32 DrawTriangles(dst ImageID, srcs [graphics.ShaderImageNum]ImageID, offsets [graphics.ShaderImageNum - 1][2]float32, shader ShaderID, indexLen int, indexOffset int, mode CompositeMode, colorM ColorM, filter Filter, address Address, dstRegion, srcRegion Region, uniforms []interface{}, evenOdd bool) error }
type Image ¶
type Image interface { ID() ImageID Dispose() IsInvalidated() bool Pixels() ([]byte, error) ReplacePixels(args []*ReplacePixelsArgs) }
type Input ¶
type Input interface { AppendInputChars(runes []rune) []rune AppendGamepadIDs(gamepadIDs []GamepadID) []GamepadID AppendTouchIDs(touchIDs []TouchID) []TouchID CursorPosition() (x, y int) GamepadSDLID(id GamepadID) string GamepadName(id GamepadID) string GamepadAxisValue(id GamepadID, axis int) float64 GamepadAxisNum(id GamepadID) int GamepadButtonNum(id GamepadID) int IsGamepadButtonPressed(id GamepadID, button GamepadButton) bool IsKeyPressed(key Key) bool IsMouseButtonPressed(button MouseButton) bool IsStandardGamepadButtonPressed(id GamepadID, button StandardGamepadButton) bool IsStandardGamepadLayoutAvailable(id GamepadID) bool StandardGamepadAxisValue(id GamepadID, button StandardGamepadAxis) float64 UpdateStandardGamepadLayoutMappings(mapping string) (bool, error) TouchPosition(id TouchID) (x, y int) Wheel() (xoff, yoff float64) }
type Key ¶
type Key int
const ( KeyA Key = iota 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 KeyAltLeft KeyAltRight KeyArrowDown KeyArrowLeft KeyArrowRight KeyArrowUp KeyBackquote KeyBackslash KeyBackspace KeyBracketLeft KeyBracketRight KeyCapsLock KeyComma KeyContextMenu KeyControlLeft KeyControlRight KeyDelete KeyDigit0 KeyDigit1 KeyDigit2 KeyDigit3 KeyDigit4 KeyDigit5 KeyDigit6 KeyDigit7 KeyDigit8 KeyDigit9 KeyEnd KeyEnter KeyEqual KeyEscape KeyF1 KeyF2 KeyF3 KeyF4 KeyF5 KeyF6 KeyF7 KeyF8 KeyF9 KeyF10 KeyF11 KeyF12 KeyHome KeyInsert KeyMetaLeft KeyMetaRight KeyMinus KeyNumLock KeyNumpad0 KeyNumpad1 KeyNumpad2 KeyNumpad3 KeyNumpad4 KeyNumpad5 KeyNumpad6 KeyNumpad7 KeyNumpad8 KeyNumpad9 KeyNumpadAdd KeyNumpadDecimal KeyNumpadDivide KeyNumpadEnter KeyNumpadEqual KeyNumpadMultiply KeyNumpadSubtract KeyPageDown KeyPageUp KeyPause KeyPeriod KeyPrintScreen KeyQuote KeyScrollLock KeySemicolon KeyShiftLeft KeyShiftRight KeySlash KeySpace KeyTab KeyReserved0 KeyReserved1 KeyReserved2 KeyReserved3 )
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 ¶
type StandardGamepadAxis ¶ added in v2.2.0
type StandardGamepadAxis int
const ( StandardGamepadAxisLeftStickHorizontal StandardGamepadAxis = iota StandardGamepadAxisLeftStickVertical StandardGamepadAxisRightStickHorizontal StandardGamepadAxisRightStickVertical StandardGamepadAxisMax = StandardGamepadAxisRightStickVertical )
type StandardGamepadButton ¶ added in v2.2.0
type StandardGamepadButton int
const ( StandardGamepadButtonRightBottom StandardGamepadButton = iota StandardGamepadButtonRightRight StandardGamepadButtonRightLeft StandardGamepadButtonRightTop StandardGamepadButtonFrontTopLeft StandardGamepadButtonFrontTopRight StandardGamepadButtonFrontBottomLeft StandardGamepadButtonFrontBottomRight StandardGamepadButtonCenterLeft StandardGamepadButtonCenterRight StandardGamepadButtonLeftStick StandardGamepadButtonRightStick StandardGamepadButtonLeftTop StandardGamepadButtonLeftBottom StandardGamepadButtonLeftLeft StandardGamepadButtonLeftRight StandardGamepadButtonCenterCenter StandardGamepadButtonMax = StandardGamepadButtonCenterCenter )
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 IsFocused() bool ScreenSizeInFullscreen() (int, int) ResetForFrame() CursorMode() CursorMode SetCursorMode(mode CursorMode) CursorShape() CursorShape SetCursorShape(shape CursorShape) IsFullscreen() bool SetFullscreen(fullscreen bool) IsRunnableOnUnfocused() bool SetRunnableOnUnfocused(runnableOnUnfocused bool) FPSMode() FPSMode SetFPSMode(mode FPSMode) ScheduleFrame() IsScreenTransparent() bool SetScreenTransparent(transparent bool) SetInitFocused(focused 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 ¶
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) SizeLimits() (minw, minh, maxw, maxh int) SetSizeLimits(minw, minh, maxw, maxh int) IsFloating() bool SetFloating(floating bool) Maximize() IsMaximized() bool Minimize() IsMinimized() bool SetIcon(iconImages []image.Image) SetTitle(title string) Restore() IsBeingClosed() bool SetClosingHandled(handled bool) IsClosingHandled() bool }