offscreen

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package offscreen provides placeholder implementations of goosi interfaces to allow for offscreen testing and capturing of apps.

Index

Constants

This section is empty.

Variables

View Source
var TheApp = &App{AppSingle: base.NewAppSingle[*Drawer, *Window]()}

TheApp is the single goosi.App for the offscreen platform

Functions

func Main

func Main(f func(goosi.App))

Main is called from main thread when it is time to start running the main loop. When function f returns, the app ends automatically.

Types

type App added in v0.0.15

type App struct {
	base.AppSingle[*Drawer, *Window]

	// TempDataDir is the path of the app data directory, used as the
	// return value of [App.DataDir]. It is set to a temporary directory,
	// as offscreen tests should not be dependent on user preferences and
	// other data.
	TempDataDir string
}

App is the goosi.App implementation for the offscreen platform

func (*App) DataDir added in v0.0.18

func (a *App) DataDir() string

func (*App) GetScreens added in v0.0.23

func (a *App) GetScreens()

func (*App) NewWindow added in v0.0.15

func (a *App) NewWindow(opts *goosi.NewWindowOptions) (goosi.Window, error)

NewWindow creates a new window with the given options. It waits for the underlying system window to be created first. Also, it hides all other windows and shows the new one.

func (*App) Platform added in v0.0.15

func (a *App) Platform() goosi.Platforms

func (*App) QuitClean added in v0.0.25

func (a *App) QuitClean()

type Drawer added in v0.0.15

type Drawer struct {
	// MaxTxts is the max number of textures
	MaxTxts int

	// Image is the target render image
	Image *image.RGBA

	// Images is a stack of images indexed by render scene index and then layer number
	Images [][]*image.RGBA
}

Drawer is the implementation of goosi.Drawer for the offscreen platform

func (*Drawer) ConfigImageDefaultFormat added in v0.0.15

func (dw *Drawer) ConfigImageDefaultFormat(idx int, width int, height int, layers int)

ConfigImageDefaultFormat configures the draw image at the given index to fit the default image format specified by the given width, height, and number of layers.

func (*Drawer) Copy added in v0.0.15

func (dw *Drawer) Copy(idx, layer int, dp image.Point, sr image.Rectangle, op draw.Op, flipY bool) error

Copy copies texture at given index and layer to render target. dp is the destination point, sr is the source region (set to image.ZR zero rect for all), op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing flipY = flipY axis when drawing this image

func (*Drawer) DestBounds added in v0.0.15

func (dw *Drawer) DestBounds() image.Rectangle

DestBounds returns the bounds of the render destination

func (*Drawer) EndDraw added in v0.0.15

func (dw *Drawer) EndDraw()

EndDraw ends image drawing rendering process on render target. This is the function that actually sends the image to the capture channel.

func (*Drawer) MaxTextures added in v0.0.15

func (dw *Drawer) MaxTextures() int

MaxTextures returns the max number of textures for drawing

func (*Drawer) Scale added in v0.0.15

func (dw *Drawer) Scale(idx, layer int, dr image.Rectangle, sr image.Rectangle, op draw.Op, flipY bool) error

Scale copies texture at given index and layer to render target, scaling the region defined by src and sr to the destination such that sr in src-space is mapped to dr in dst-space. dr is the destination rectangle sr is the source region (set to image.ZR zero rect for all), op is the drawing operation: Src = copy source directly (blit), Over = alpha blend with existing flipY = flipY axis when drawing this image

func (*Drawer) SetGoImage added in v0.0.15

func (dw *Drawer) SetGoImage(idx, layer int, img image.Image, flipY bool)

SetGoImage sets given Go image as a drawing source to given image index, and layer, used in subsequent Draw methods. A standard Go image is rendered upright on a standard surface. Set flipY to true to flip.

func (*Drawer) SetMaxTextures added in v0.0.15

func (dw *Drawer) SetMaxTextures(maxTextures int)

SetMaxTextures updates the max number of textures for drawing Must call this prior to doing any allocation of images.

func (*Drawer) StartDraw added in v0.0.15

func (dw *Drawer) StartDraw(descIdx int)

StartDraw starts image drawing rendering process on render target No images can be added or set after this point. descIdx is the descriptor set to use -- choose this based on the bank of 16 texture values if number of textures > MaxTexturesPerSet. This is a no-op on offscreen; if rendering logic is done here instead of EndDraw, everything is delayed by one render because Scale and Copy are called after StartDraw but before EndDraw, and we need them to be called before actually rendering the image to the capture channel.

func (*Drawer) Surface added in v0.0.15

func (dw *Drawer) Surface() any

func (*Drawer) SyncImages added in v0.0.15

func (dw *Drawer) SyncImages()

SyncImages must be called after images have been updated, to sync memory up to the GPU.

func (*Drawer) UseTextureSet added in v0.0.15

func (dw *Drawer) UseTextureSet(descIdx int)

UseTextureSet selects the descriptor set to use -- choose this based on the bank of 16 texture values if number of textures > MaxTexturesPerSet.

type Window added in v0.0.15

type Window struct {
	base.WindowSingle[*App]
}

Window is the implementation of goosi.Window for the offscreen platform.

func (*Window) Handle added in v0.0.15

func (w *Window) Handle() any

Jump to

Keyboard shortcuts

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