ui

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NearestFilterShader = &Shader{shader: mipmap.NearestFilterShader}
	LinearFilterShader  = &Shader{shader: mipmap.LinearFilterShader}
)
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

func DumpImages

func DumpImages(dir string) (string, error)

func GraphicsDriverForTesting

func GraphicsDriverForTesting() graphicsdriver.Graphics

func IsScreenClearedEveryFrame

func IsScreenClearedEveryFrame() bool

func IsScreenTransparentAvailable

func IsScreenTransparentAvailable() bool

func KeyName

func KeyName(key Key) string

func SetFPSMode

func SetFPSMode(fpsMode FPSModeType)

func SetPanicOnErrorOnReadingPixelsForTesting

func SetPanicOnErrorOnReadingPixelsForTesting(value bool)

func SetScreenClearedEveryFrame

func SetScreenClearedEveryFrame(cleared bool)

Types

type CursorMode

type CursorMode int
const (
	CursorModeVisible CursorMode = iota
	CursorModeHidden
	CursorModeCaptured
)

type CursorShape

type CursorShape int
const (
	CursorShapeDefault CursorShape = iota
	CursorShapeText
	CursorShapeCrosshair
	CursorShapePointer
	CursorShapeEWResize
	CursorShapeNSResize
)

type FPSModeType

type FPSModeType int
const (
	FPSModeVsyncOn FPSModeType = iota
	FPSModeVsyncOffMaximum
	FPSModeVsyncOffMinimum
)

func FPSMode

func FPSMode() FPSModeType

type Game

type Game interface {
	NewOffscreenImage(width, height int) *Image
	NewScreenImage(width, height int) *Image
	Layout(outsideWidth, outsideHeight float64) (screenWidth, screenHeight float64)
	UpdateInputState(fn func(*InputState))
	Update() error
	DrawOffscreen() error
	DrawFinalScreen(scale, offsetX, offsetY float64)
}

type GraphicsLibrary

type GraphicsLibrary int
const (
	GraphicsLibraryAuto GraphicsLibrary = iota
	GraphicsLibraryOpenGL
	GraphicsLibraryDirectX
	GraphicsLibraryMetal
	GraphicsLibraryUnknown
)

func GetGraphicsLibrary

func GetGraphicsLibrary() GraphicsLibrary

func (GraphicsLibrary) String

func (g GraphicsLibrary) String() string

type Image

type Image struct {
	// contains filtered or unexported fields
}

func NewImage

func NewImage(width, height int, imageType atlas.ImageType) *Image

func (*Image) DrawTriangles

func (i *Image) DrawTriangles(srcs [graphics.ShaderImageCount]*Image, vertices []float32, indices []uint16, blend graphicsdriver.Blend, dstRegion, srcRegion graphicsdriver.Region, subimageOffsets [graphics.ShaderImageCount - 1][2]float32, shader *Shader, uniforms []uint32, evenOdd bool, canSkipMipmap bool, antialias bool)

func (*Image) DumpScreenshot

func (i *Image) DumpScreenshot(name string, blackbg bool) (string, error)

func (*Image) Fill

func (i *Image) Fill(r, g, b, a float32, region image.Rectangle)

func (*Image) MarkDisposed

func (i *Image) MarkDisposed()

func (*Image) ReadPixels

func (i *Image) ReadPixels(pixels []byte, region image.Rectangle)

func (*Image) WritePixels

func (i *Image) WritePixels(pix []byte, region image.Rectangle)

type InputState

type InputState struct {
	KeyPressed         [KeyMax + 1]bool
	MouseButtonPressed [MouseButtonMax + 1]bool
	CursorX            int
	CursorY            int
	WheelX             float64
	WheelY             float64
	Touches            []Touch
	Runes              []rune
	WindowBeingClosed  bool
	DroppedFiles       fs.FS
}

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
	KeyMax = KeyReserved3
)

func (Key) String

func (k Key) String() string

type MouseButton

type MouseButton int
const (
	MouseButton0   MouseButton = iota // The 'left' button
	MouseButton1                      // The 'right' button
	MouseButton2                      // The 'middle' button
	MouseButton3                      // The additional button (usually browser-back)
	MouseButton4                      // The additional button (usually browser-forward)
	MouseButtonMax = MouseButton4
)

type RunOptions

type RunOptions struct {
	GraphicsLibrary   GraphicsLibrary
	InitUnfocused     bool
	ScreenTransparent bool
	SkipTaskbar       bool
}

type Shader

type Shader struct {
	// contains filtered or unexported fields
}

func NewShader

func NewShader(ir *shaderir.Program) *Shader

func (*Shader) AppendUniforms

func (s *Shader) AppendUniforms(dst []uint32, uniforms map[string]any) []uint32

func (*Shader) MarkDisposed

func (s *Shader) MarkDisposed()

type Touch

type Touch struct {
	ID TouchID
	X  int
	Y  int
}

type TouchID

type TouchID int

type UserInterface

type UserInterface struct {
	// contains filtered or unexported fields
}

func Get

func Get() *UserInterface

func (*UserInterface) CursorMode

func (u *UserInterface) CursorMode() CursorMode

func (*UserInterface) CursorShape

func (u *UserInterface) CursorShape() CursorShape

func (*UserInterface) DeviceScaleFactor

func (u *UserInterface) DeviceScaleFactor() float64

func (*UserInterface) IsFocused

func (u *UserInterface) IsFocused() bool

func (*UserInterface) IsFullscreen

func (u *UserInterface) IsFullscreen() bool

func (*UserInterface) IsRunnableOnUnfocused

func (u *UserInterface) IsRunnableOnUnfocused() bool

func (*UserInterface) Run

func (u *UserInterface) Run(game Game, options *RunOptions) error

func (*UserInterface) ScheduleFrame

func (u *UserInterface) ScheduleFrame()

func (*UserInterface) ScreenSizeInFullscreen

func (u *UserInterface) ScreenSizeInFullscreen() (int, int)

func (*UserInterface) SetCursorMode

func (u *UserInterface) SetCursorMode(mode CursorMode)

func (*UserInterface) SetCursorShape

func (u *UserInterface) SetCursorShape(shape CursorShape)

func (*UserInterface) SetFPSMode

func (u *UserInterface) SetFPSMode(mode FPSModeType)

func (*UserInterface) SetFullscreen

func (u *UserInterface) SetFullscreen(fullscreen bool)

func (*UserInterface) SetRunnableOnUnfocused

func (u *UserInterface) SetRunnableOnUnfocused(runnableOnUnfocused bool)

func (*UserInterface) Window

func (u *UserInterface) Window() Window

type Window

type Window interface {
	IsDecorated() bool
	SetDecorated(decorated bool)
	ResizingMode() WindowResizingMode
	SetResizingMode(mode WindowResizingMode)
	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()
	SetClosingHandled(handled bool)
	IsClosingHandled() bool
}

type WindowResizingMode

type WindowResizingMode int
const (
	WindowResizingModeDisabled WindowResizingMode = iota
	WindowResizingModeOnlyFullscreenEnabled
	WindowResizingModeEnabled
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL