-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
57 lines (45 loc) · 1.36 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package render
import (
"image"
"git.kirsle.net/go/render/event"
)
// Engine is the interface for the rendering engine, keeping SDL-specific stuff
// far away from the core of Doodle.
type Engine interface {
Setup() error
// Poll for events like keypresses and mouse clicks.
Poll() (*event.State, error)
GetTicks() uint32
WindowSize() (w, h int)
// Present presents the current state to the screen.
Present() error
// Clear the full canvas and set this color.
Clear(Color)
SetTitle(string)
DrawPoint(Color, Point)
DrawLine(Color, Point, Point)
DrawRect(Color, Rect)
DrawBox(Color, Rect)
DrawText(Text, Point) error
ComputeTextRect(Text) (Rect, error)
// Texture caching.
StoreTexture(name string, img image.Image) (Texturer, error)
LoadTexture(name string) (Texturer, error)
Copy(t Texturer, src, dst Rect)
// Teardown and free memory for all textures, returning the number
// of textures that were freed.
FreeTextures() int
// Delay for a moment using the render engine's delay method,
// implemented by sdl.Delay(uint32)
Delay(uint32)
// Tasks that the Setup function should defer until tear-down.
Teardown()
Loop() error // maybe?
}
// Texturer is a stored image texture used by the rendering engine while
// abstracting away its inner workings.
type Texturer interface {
Size() Rect
Image() image.Image
Free() error // teardown and free memory
}