-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtexture.go
83 lines (73 loc) · 2.39 KB
/
texture.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package banana
import (
"image"
"github.com/dfirebaugh/banana/graphics"
)
func UploadTexture(img image.Image) uint32 {
return banana.graphicsBackend.UploadTexture(img)
}
func UpdateTexture(textureID uint32, img image.Image, xOffset, yOffset float32) {
banana.graphicsBackend.UpdateTexture(textureID, img, int(xOffset), int(yOffset))
}
type TextureRenderOptions struct {
TextureIndex int
X, Y float32
RectWidth, RectHeight float32
DesiredWidth, DesiredHeight float32
Scale float32
RectX, RectY float32
Width, Height float32
FlipX, FlipY bool
Rotation float32
}
func RenderTexture(textureHandle uint32, options *TextureRenderOptions) {
ensureSetupCompletion()
banana.graphicsBackend.RenderTexture(
textureHandle,
&graphics.TextureRenderOptions{
TextureIndex: float32(options.TextureIndex),
X: options.X,
Y: options.Y,
RectWidth: options.RectWidth,
RectHeight: options.RectHeight,
DesiredWidth: options.DesiredWidth,
DesiredHeight: options.DesiredHeight,
Scale: options.Scale,
RectX: options.RectX,
RectY: options.RectY,
Width: options.Width,
Height: options.Height,
FlipX: options.FlipX,
FlipY: options.FlipY,
Rotation: options.Rotation,
})
}
type Framebuffer graphics.Framebuffer
func RenderFramebuffer(fb Framebuffer, options *TextureRenderOptions) {
ensureSetupCompletion()
graphicsOptions := &graphics.TextureRenderOptions{
TextureIndex: float32(options.TextureIndex),
X: options.X,
Y: options.Y,
RectWidth: options.RectWidth,
RectHeight: options.RectHeight,
DesiredWidth: options.DesiredWidth,
DesiredHeight: options.DesiredHeight,
Scale: options.Scale,
RectX: options.RectX,
RectY: options.RectY,
Width: options.Width,
Height: options.Height,
FlipX: options.FlipX,
FlipY: options.FlipY,
Rotation: options.Rotation,
}
banana.graphicsBackend.RenderFramebuffer(fb, graphicsOptions)
}
func AddFramebuffer(width, height int) (Framebuffer, error) {
ensureSetupCompletion()
return banana.graphicsBackend.AddFramebuffer(width, height)
}
func ResizeFramebuffer(fb Framebuffer, width, height int) {
fb.Resize(width, height)
}