Documentation ¶
Overview ¶
Package sdl provides an SDL2 renderer for Doodle.
Package sdl provides an SDL2 renderer for Doodle.
Index ¶
- Variables
- func ColorToSDL(c render.Color) sdl.Color
- func InstallFont(filename string, binary []byte)
- func LoadFont(filename string, size int) (*ttf.Font, error)
- func RectToSDL(r render.Rect) sdl.Rect
- type Font
- type GameController
- func (gc *GameController) ButtonA() bool
- func (gc *GameController) ButtonB() bool
- func (gc *GameController) ButtonDown() bool
- func (gc *GameController) ButtonHome() bool
- func (gc *GameController) ButtonL1() bool
- func (gc *GameController) ButtonL2() bool
- func (gc *GameController) ButtonLStick() bool
- func (gc *GameController) ButtonLeft() bool
- func (gc *GameController) ButtonR1() bool
- func (gc *GameController) ButtonR2() bool
- func (gc *GameController) ButtonRStick() bool
- func (gc *GameController) ButtonRight() bool
- func (gc *GameController) ButtonSelect() bool
- func (gc *GameController) ButtonStart() bool
- func (gc *GameController) ButtonUp() bool
- func (gc *GameController) ButtonX() bool
- func (gc *GameController) ButtonY() bool
- func (gc *GameController) GetAxisState(name string) int
- func (gc *GameController) GetButtonState(name string) bool
- func (gc *GameController) ID() int
- func (gc *GameController) LeftStick() event.Vector
- func (gc *GameController) LeftTrigger() float64
- func (gc *GameController) Name() string
- func (gc *GameController) RightStick() event.Vector
- func (gc *GameController) RightTrigger() float64
- func (gc *GameController) SetAxisState(name string, value int)
- func (gc *GameController) SetButtonState(name string, pressed bool)
- type Renderer
- func (r *Renderer) Clear(color render.Color)
- func (r *Renderer) ComputeTextRect(text render.Text) (render.Rect, error)
- func (r *Renderer) Copy(t render.Texturer, src, dst render.Rect)
- func (r *Renderer) CountTextures() int
- func (r *Renderer) Delay(time uint32)
- func (r *Renderer) DrawBox(color render.Color, rect render.Rect)
- func (r *Renderer) DrawLine(color render.Color, a, b render.Point)
- func (r *Renderer) DrawPoint(color render.Color, point render.Point)
- func (r *Renderer) DrawRect(color render.Color, rect render.Rect)
- func (r *Renderer) DrawText(text render.Text, point render.Point) error
- func (r *Renderer) FreeTextures() int
- func (r *Renderer) GetSDL2Renderer() *sdl.Renderer
- func (r *Renderer) GetTicks() uint32
- func (r *Renderer) ListTextures() []string
- func (r *Renderer) LoadTexture(name string) (render.Texturer, error)
- func (r *Renderer) Loop() error
- func (r *Renderer) Maximize()
- func (r *Renderer) Poll() (*event.State, error)
- func (r *Renderer) Present() error
- func (r *Renderer) SetTitle(title string)
- func (r *Renderer) SetWindowIcon(icon image.Image) error
- func (r *Renderer) Setup() error
- func (r *Renderer) ShowCursor(v bool)
- func (r *Renderer) StoreTexture(name string, img image.Image) (render.Texturer, error)
- func (r *Renderer) Teardown()
- func (r *Renderer) WindowSize() (int, int)
- type Texture
Constants ¶
This section is empty.
Variables ¶
var ( DebugWindowEvents = false DebugTouchEvents = false DebugMouseEvents = false DebugClickEvents = false DebugKeyEvents = false DebugControllerEvents = false )
Debug certain SDL events
var DefaultFontFilename = "DejaVuSans.ttf"
TODO: font filenames
var ( // For controllers having a digital (non-analog) Left/Right Trigger, the press percentage // for which to consider it a boolean press. TriggerAxisBooleanThreshold float64 = 0.5 )
User tuneable properties.
Functions ¶
func ColorToSDL ¶
ColorToSDL converts Doodle's Color type to an sdl.Color.
func InstallFont ¶
InstallFont preloads the font cache using TTF binary data in memory.
Types ¶
type Font ¶
type Font struct { Filename string // contains filtered or unexported fields }
Font holds cached SDL_TTF structures for loaded fonts. They are created automatically when fonts are either preinstalled (InstallFont) or loaded for the first time as demanded by the DrawText method.
type GameController ¶
type GameController struct {
// contains filtered or unexported fields
}
GameController holds an abstraction around SDL2 GameControllers.
func NewGameController ¶
func NewGameController(index int, name string, ctrl *sdl.GameController) *GameController
NewGameController creates a GameController from an SDL2 controller.
func (*GameController) ButtonA ¶
func (gc *GameController) ButtonA() bool
ButtonA returns whether the logical Xbox button is pressed.
func (*GameController) ButtonB ¶
func (gc *GameController) ButtonB() bool
ButtonB returns whether the logical Xbox button is pressed.
func (*GameController) ButtonDown ¶
func (gc *GameController) ButtonDown() bool
ButtonDown returns whether the Xbox D-Pad button is pressed.
func (*GameController) ButtonHome ¶
func (gc *GameController) ButtonHome() bool
ButtonHome returns whether the Xbox "guide" button is pressed.
func (*GameController) ButtonL1 ¶
func (gc *GameController) ButtonL1() bool
ButtonL1 returns whether the Left Shoulder button is pressed.
func (*GameController) ButtonL2 ¶
func (gc *GameController) ButtonL2() bool
ButtonL2 returns whether the Left Trigger (digital) button is pressed. Returns true if the LeftTrigger is 50% pressed or TriggerAxisBooleanThreshold.
func (*GameController) ButtonLStick ¶
func (gc *GameController) ButtonLStick() bool
ButtonLStick returns whether the Left Stick button is pressed.
func (*GameController) ButtonLeft ¶
func (gc *GameController) ButtonLeft() bool
ButtonLeft returns whether the Xbox D-Pad button is pressed.
func (*GameController) ButtonR1 ¶
func (gc *GameController) ButtonR1() bool
ButtonR1 returns whether the Right Shoulder button is pressed.
func (*GameController) ButtonR2 ¶
func (gc *GameController) ButtonR2() bool
ButtonR2 returns whether the Left Trigger (digital) button is pressed. Returns true if the LeftTrigger is 50% pressed or TriggerAxisBooleanThreshold.
func (*GameController) ButtonRStick ¶
func (gc *GameController) ButtonRStick() bool
ButtonRStick returns whether the Right Stick button is pressed.
func (*GameController) ButtonRight ¶
func (gc *GameController) ButtonRight() bool
ButtonRight returns whether the Xbox D-Pad button is pressed.
func (*GameController) ButtonSelect ¶
func (gc *GameController) ButtonSelect() bool
ButtonSelect returns whether the Xbox "back" button is pressed.
func (*GameController) ButtonStart ¶
func (gc *GameController) ButtonStart() bool
ButtonStart returns whether the logical Xbox button is pressed.
func (*GameController) ButtonUp ¶
func (gc *GameController) ButtonUp() bool
ButtonUp returns whether the Xbox D-Pad button is pressed.
func (*GameController) ButtonX ¶
func (gc *GameController) ButtonX() bool
ButtonX returns whether the logical Xbox button is pressed.
func (*GameController) ButtonY ¶
func (gc *GameController) ButtonY() bool
ButtonY returns whether the logical Xbox button is pressed.
func (*GameController) GetAxisState ¶
func (gc *GameController) GetAxisState(name string) int
GetAxisState returns the underlying SDL2 axis state.
func (*GameController) GetButtonState ¶
func (gc *GameController) GetButtonState(name string) bool
GetButtonState returns the button state by SDL2 button name.
func (*GameController) ID ¶
func (gc *GameController) ID() int
ID returns the controller index as SDL2 knows it.
func (*GameController) LeftStick ¶
func (gc *GameController) LeftStick() event.Vector
LeftStick returns the vector of X and Y of the left analog stick.
func (*GameController) LeftTrigger ¶
func (gc *GameController) LeftTrigger() float64
LeftTrigger returns the vector of the left analog trigger.
func (*GameController) Name ¶
func (gc *GameController) Name() string
Name returns the controller name.
func (*GameController) RightStick ¶
func (gc *GameController) RightStick() event.Vector
RightStick returns the vector of X and Y of the right analog stick.
func (*GameController) RightTrigger ¶
func (gc *GameController) RightTrigger() float64
RightTrigger returns the vector of the left analog trigger.
func (*GameController) SetAxisState ¶
func (gc *GameController) SetAxisState(name string, value int)
SetAxisState sets the axis state.
func (*GameController) SetButtonState ¶
func (gc *GameController) SetButtonState(name string, pressed bool)
SetButtonState sets the state using the SDL2 button names.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer manages the SDL state.
func (*Renderer) ComputeTextRect ¶
ComputeTextRect computes and returns a Rect for how large the text would appear if rendered.
func (*Renderer) CountTextures ¶
CountTextures is a custom function for the SDL2 Engine only that returns the size of the engine texture cache.
func (*Renderer) FreeTextures ¶
FreeTextures flushes the internal cache of SDL2 textures and frees their memory.
func (*Renderer) GetSDL2Renderer ¶
Private access methods
func (*Renderer) ListTextures ¶
ListTextures is a custom function to peek into the SDL2 texture cache names.
func (*Renderer) LoadTexture ¶
LoadTexture initializes a texture from a bitmap image.
func (*Renderer) SetWindowIcon ¶
SetWindowIcon sets an icon for the SDL2 window.
func (*Renderer) ShowCursor ¶
ShowCursor sets whether the mouse cursor should be visible.
func (*Renderer) StoreTexture ¶
StoreTexture caches an SDL texture from a bitmap.
func (*Renderer) WindowSize ¶
WindowSize returns the SDL window size.