Documentation ¶
Index ¶
- Variables
- func InitialWindowPosition(mw, mh, ww, wh int) (x, y int)
- func IsScreenTransparentAvailable() bool
- func SetPanicOnErrorOnReadingPixelsForTesting(value bool)
- type CursorMode
- type CursorShape
- type FPSModeType
- type Game
- type GraphicsLibrary
- type Image
- func (i *Image) Deallocate()
- func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, ...)
- func (i *Image) DumpScreenshot(name string, blackbg bool) (string, error)
- func (i *Image) Fill(r, g, b, a float32, region image.Rectangle)
- func (i *Image) ReadPixels(pixels []byte, region image.Rectangle)
- func (i *Image) WritePixels(pix []byte, region image.Rectangle)
- type InputState
- type Key
- type Monitor
- type MouseButton
- type RunOptions
- type Shader
- type Touch
- type TouchID
- type UserInterface
- func (u *UserInterface) AppendMonitors(monitors []*Monitor) []*Monitor
- func (u *UserInterface) CursorMode() CursorMode
- func (u *UserInterface) CursorShape() CursorShape
- func (u *UserInterface) DumpImages(dir string) (string, error)
- func (u *UserInterface) FPSMode() FPSModeType
- func (u *UserInterface) GraphicsDriverForTesting() graphicsdriver.Graphics
- func (u *UserInterface) GraphicsLibrary() GraphicsLibrary
- func (u *UserInterface) IsFocused() bool
- func (u *UserInterface) IsFullscreen() bool
- func (u *UserInterface) IsRunnableOnUnfocused() bool
- func (u *UserInterface) IsScreenClearedEveryFrame() bool
- func (u *UserInterface) KeyName(key Key) string
- func (u *UserInterface) LogicalPositionToClientPositionInNativePixels(x, y float64) (float64, float64)
- func (u *UserInterface) Monitor() *Monitor
- func (u *UserInterface) NewImage(width, height int, imageType atlas.ImageType) *Image
- func (u *UserInterface) Run(game Game, options *RunOptions) error
- func (u *UserInterface) RunOnMainThread(f func())
- func (u *UserInterface) ScheduleFrame()
- func (u *UserInterface) ScreenSizeInFullscreen() (int, int)
- func (u *UserInterface) SetCursorMode(mode CursorMode)
- func (u *UserInterface) SetCursorShape(shape CursorShape)
- func (u *UserInterface) SetFPSMode(mode FPSModeType)
- func (u *UserInterface) SetFullscreen(fullscreen bool)
- func (u *UserInterface) SetRunnableOnUnfocused(runnableOnUnfocused bool)
- func (u *UserInterface) SetScreenClearedEveryFrame(cleared bool)
- func (u *UserInterface) Tick() uint64
- func (u *UserInterface) Window() Window
- type Window
- type WindowResizingMode
Constants ¶
This section is empty.
Variables ¶
View Source
var ( NearestFilterShader = &Shader{shader: atlas.NearestFilterShader} LinearFilterShader = &Shader{shader: atlas.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 InitialWindowPosition ¶ added in v2.6.0
InitialWindowPosition returns the position for centering the given second width/height pair within the first width/height pair.
func IsScreenTransparentAvailable ¶ added in v2.5.0
func IsScreenTransparentAvailable() bool
func SetPanicOnErrorOnReadingPixelsForTesting ¶
func SetPanicOnErrorOnReadingPixelsForTesting(value 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 CursorShapeNESWResize CursorShapeNWSEResize CursorShapeMove CursorShapeNotAllowed )
type FPSModeType ¶
type FPSModeType int
const ( FPSModeVsyncOn FPSModeType = iota FPSModeVsyncOffMaximum FPSModeVsyncOffMinimum )
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 ¶ added in v2.4.0
type GraphicsLibrary int
const ( GraphicsLibraryAuto GraphicsLibrary = iota GraphicsLibraryUnknown GraphicsLibraryOpenGL GraphicsLibraryDirectX GraphicsLibraryMetal GraphicsLibraryPlayStation5 )
func (GraphicsLibrary) String ¶ added in v2.5.0
func (g GraphicsLibrary) String() string
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
func (*Image) Deallocate ¶ added in v2.7.0
func (i *Image) Deallocate()
func (*Image) DrawTriangles ¶
func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertices []float32, indices []uint32, blend graphicsdriver.Blend, dstRegion image.Rectangle, srcRegions [graphics.ShaderSrcImageCount]image.Rectangle, shader *Shader, uniforms []uint32, fillRule graphicsdriver.FillRule, canSkipMipmap bool, antialias bool, hint restorable.Hint)
func (*Image) DumpScreenshot ¶
func (*Image) ReadPixels ¶ added in v2.4.0
type InputState ¶ added in v2.5.0
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 KeyF13 KeyF14 KeyF15 KeyF16 KeyF17 KeyF18 KeyF19 KeyF20 KeyF21 KeyF22 KeyF23 KeyF24 KeyHome KeyInsert KeyIntlBackslash 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 )
type Monitor ¶ added in v2.6.0
type Monitor struct {
// contains filtered or unexported fields
}
Monitor is a wrapper around glfw.Monitor.
func (*Monitor) DeviceScaleFactor ¶ added in v2.7.0
DeviceScaleFactor is concurrent-safe as contentScale is immutable.
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 ¶ added in v2.5.0
type RunOptions struct { GraphicsLibrary GraphicsLibrary InitUnfocused bool ScreenTransparent bool SkipTaskbar bool SingleThread bool DisableHiDPI bool ColorSpace graphicsdriver.ColorSpace X11ClassName string X11InstanceName string StrictContextRestoration bool }
type Shader ¶
type Shader struct {
// contains filtered or unexported fields
}
func (*Shader) AppendUniforms ¶ added in v2.5.0
func (*Shader) Deallocate ¶ added in v2.7.0
func (s *Shader) Deallocate()
type UserInterface ¶
type UserInterface struct {
// contains filtered or unexported fields
}
func Get ¶
func Get() *UserInterface
func (*UserInterface) AppendMonitors ¶ added in v2.6.0
func (u *UserInterface) AppendMonitors(monitors []*Monitor) []*Monitor
AppendMonitors appends the current monitors to the passed in mons slice and returns it.
func (*UserInterface) CursorMode ¶
func (u *UserInterface) CursorMode() CursorMode
func (*UserInterface) CursorShape ¶
func (u *UserInterface) CursorShape() CursorShape
func (*UserInterface) DumpImages ¶ added in v2.7.0
func (u *UserInterface) DumpImages(dir string) (string, error)
func (*UserInterface) FPSMode ¶ added in v2.7.0
func (u *UserInterface) FPSMode() FPSModeType
func (*UserInterface) GraphicsDriverForTesting ¶ added in v2.7.0
func (u *UserInterface) GraphicsDriverForTesting() graphicsdriver.Graphics
func (*UserInterface) GraphicsLibrary ¶ added in v2.7.0
func (u *UserInterface) GraphicsLibrary() GraphicsLibrary
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) IsScreenClearedEveryFrame ¶ added in v2.7.0
func (u *UserInterface) IsScreenClearedEveryFrame() bool
func (*UserInterface) KeyName ¶ added in v2.7.0
func (u *UserInterface) KeyName(key Key) string
func (*UserInterface) LogicalPositionToClientPositionInNativePixels ¶ added in v2.7.0
func (u *UserInterface) LogicalPositionToClientPositionInNativePixels(x, y float64) (float64, float64)
func (*UserInterface) Monitor ¶ added in v2.6.0
func (u *UserInterface) Monitor() *Monitor
Monitor returns the window's current monitor. Returns nil if there is no current monitor yet.
func (*UserInterface) NewImage ¶ added in v2.7.0
func (u *UserInterface) NewImage(width, height int, imageType atlas.ImageType) *Image
func (*UserInterface) Run ¶
func (u *UserInterface) Run(game Game, options *RunOptions) error
func (*UserInterface) RunOnMainThread ¶ added in v2.7.0
func (u *UserInterface) RunOnMainThread(f func())
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) SetScreenClearedEveryFrame ¶ added in v2.7.0
func (u *UserInterface) SetScreenClearedEveryFrame(cleared bool)
func (*UserInterface) Tick ¶ added in v2.8.0
func (u *UserInterface) Tick() uint64
func (*UserInterface) Window ¶
func (u *UserInterface) Window() Window
type Window ¶
type Window interface { IsDecorated() bool SetDecorated(decorated bool) ResizingMode() WindowResizingMode SetResizingMode(mode WindowResizingMode) SetMonitor(*Monitor) 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 SetMousePassthrough(enabled bool) IsMousePassthrough() bool }
type WindowResizingMode ¶
type WindowResizingMode int
const ( WindowResizingModeDisabled WindowResizingMode = iota WindowResizingModeOnlyFullscreenEnabled WindowResizingModeEnabled )
Click to show internal directories.
Click to hide internal directories.