driver

package
Version: v2.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const GamepadButtonNum = 32

Variables

View Source
var GraphicsNotReady = errors.New("graphics not ready")

GraphicsNotReady represents that the graphics driver is not ready for recovering from the context lost.

View Source
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 Address

type Address int
const (
	AddressUnsafe Address = iota
	AddressClampToZero
	AddressRepeat
)

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
)

type Event

type Event interface{}

type Filter

type Filter int
const (
	FilterNearest Filter = iota
	FilterLinear
	FilterScreen
)

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 GamepadID

type GamepadID int

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)
	Reset() error
	SetVsyncEnabled(enabled bool)
	FramebufferYDirection() YDirection
	NeedsRestoring() bool
	IsGL() bool
	HasHighPrecisionFloat() bool
	MaxImageSize() int
	InvalidImageID() ImageID

	NewShader(program *shaderir.Program) (Shader, error)

	// Draw draws an image onto another image.
	//
	// TODO: Merge this into DrawShader.
	Draw(dst, src ImageID, indexLen int, indexOffset int, mode CompositeMode, colorM *affine.ColorM, filter Filter, address Address, dstRegion, srcRegion Region) error

	// DrawShader draws the shader.
	//
	// uniforms represents a colletion of uniform variables. The values must be one of these types:
	//
	//   * float32
	//   * []float32
	DrawShader(dst ImageID, srcs [graphics.ShaderImageNum]ImageID, offsets [graphics.ShaderImageNum - 1][2]float32, shader ShaderID, indexLen int, indexOffset int, dstRegion, srcRegion Region, mode CompositeMode, uniforms []interface{}) error
}

type Image

type Image interface {
	ID() ImageID
	Dispose()
	IsInvalidated() bool
	Pixels() ([]byte, error)
	ReplacePixels(args []*ReplacePixelsArgs)
}

type ImageID

type ImageID int

type Input

type Input interface {
	CursorPosition() (x, y int)
	GamepadSDLID(id GamepadID) string
	GamepadName(id GamepadID) string
	GamepadAxis(id GamepadID, axis int) float64
	GamepadAxisNum(id GamepadID) int
	GamepadButtonNum(id GamepadID) int
	GamepadIDs() []GamepadID
	IsGamepadButtonPressed(id GamepadID, button GamepadButton) bool
	IsKeyPressed(key Key) bool
	IsMouseButtonPressed(button MouseButton) bool
	RuneBuffer() []rune
	TouchIDs() []TouchID
	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
)

func (Key) String

func (k Key) String() string

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 Modifier

type Modifier int
const (
	ModifierShift Modifier = 1 << iota
	ModifierControl
	ModifierAlt
	ModifierCapsLock
	ModifierNumLock
)

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 Operation

type Operation int
const (
	Zero Operation = iota
	One
	SrcAlpha
	DstAlpha
	OneMinusSrcAlpha
	OneMinusDstAlpha
	DstColor
)

type Region

type Region struct {
	X      float32
	Y      float32
	Width  float32
	Height float32
}

type ReplacePixelsArgs

type ReplacePixelsArgs struct {
	Pixels []byte
	X      int
	Y      int
	Width  int
	Height int
}

type Shader

type Shader interface {
	ID() ShaderID
	Dispose()
}

type ShaderID

type ShaderID int

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 TouchID

type TouchID int

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)

	IsVsyncEnabled() bool
	SetVsyncEnabled(enabled bool)

	IsScreenTransparent() bool
	SetScreenTransparent(transparent bool)
	SetInitFocused(focused bool)

	Input() Input
	Window() Window
	Graphics() Graphics
}

type UIContext

type UIContext interface {
	Update() error
	ForceUpdate() error
	Layout(outsideWidth, outsideHeight float64)

	// AdjustPosition can be called from a different goroutine from Update's or Layout's.
	AdjustPosition(x, y float64, deviceScaleFactor float64) (float64, float64)
}

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()
}

type YDirection

type YDirection int
const (
	Upward YDirection = iota
	Downward
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL