Documentation ¶
Overview ¶
Package sdl provides a Driver for making native graphical apps.
Index ¶
- type Config
- type Driver
- func (dr *Driver) ClearCache()
- func (dr *Driver) Close()
- func (dr *Driver) Flush(frame gruid.Frame)
- func (dr *Driver) Init() error
- func (dr *Driver) PollMsg() (gruid.Msg, error)
- func (dr *Driver) PollMsgs(ctx context.Context, msgs chan<- gruid.Msg) error
- func (dr *Driver) PreventQuit()
- func (dr *Driver) SetScale(scaleX, scaleY float32)
- func (dr *Driver) SetTileManager(tm TileManager)
- func (dr *Driver) SetWindowTitle(title string)
- type TileManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { TileManager TileManager // for retrieving tiles (required) Width int32 // initial screen width in cells (default: 80) Height int32 // initial screen height in cells (default: 24) Fullscreen bool // use “real” fullscreen with a videomode change Accelerated bool // use accelerated renderer (rarely necessary) WindowTitle string // window title (default: gruid go-sdl2) WindowIcon image.Image // window icon (optional) }
Config contains configurations options for the driver.
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements gruid.Driver using the go-sdl2 bindings for the SDL library. When using an gruid.App, Start has to be used on the main routine, as the video functions of SDL are not thread safe.
func (*Driver) ClearCache ¶
func (dr *Driver) ClearCache()
ClearCache clears the tile textures internal cache.
func (*Driver) Close ¶
func (dr *Driver) Close()
Close implements gruid.Driver.Close. It releases some resources and calls sdl.Quit.
func (*Driver) Init ¶
Init implements gruid.Driver.Init. It initializes structures and calls sdl.Init().
func (*Driver) PollMsg ¶ added in v0.4.0
PollMsg makes Driver implement gruid.DriverPollMsg. It returns return an input message, if any, in a non-blocking way.
func (*Driver) PreventQuit ¶
func (dr *Driver) PreventQuit()
PreventQuit will make next call to Close keep sdl and the main window running. It can be used to chain two applications with the same sdl session and window. It is then your reponsibility to either run another application or call Close manually to properly quit.
func (*Driver) SetScale ¶
SetScale modifies the rendering scale for rendering, and updates the window size accordingly. Integer values give more accurate results.
func (*Driver) SetTileManager ¶
func (dr *Driver) SetTileManager(tm TileManager)
SetTileManager allows to change the used tile manager. If the driver is already running, change will take effect with next Flush so that the function is thread safe.
func (*Driver) SetWindowTitle ¶
SetWindowTitle sets the window title.
type TileManager ¶
type TileManager interface { // GetImage returns the image to be used for a given cell style. GetImage(gruid.Cell) image.Image // TileSize returns the (width, height) in pixels of the tiles. Both // should be positive and non-zero. TileSize() gruid.Point }
TileManager manages tiles fetching.