-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.odin
39 lines (31 loc) · 1.05 KB
/
draw.odin
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
package main
import sdl "vendor:sdl2"
import sdlF "vendor:sdl2/ttf"
drawList :: proc() {
sdl.SetRenderDrawColor(app.renderer, 255, 255, 255, 255)
}
drawBorder :: proc(thickness, x, y, w, h: i32) {
sdl.SetRenderDrawColor(app.renderer, 255, 200, 150, 255)
rect := sdl.Rect{0, 0, w, h}
sdl.RenderDrawRect(app.renderer, &rect)
for i in 0 ..= thickness {
rect.x = i
rect.y = i
sdl.RenderDrawRect(app.renderer, &rect)
}
}
drawText :: proc(x, y: i32, font: ^sdlF.Font, text: cstring, color: sdl.Color) {
surfaceMessege: ^sdl.Surface = sdlF.RenderText_Solid(font, text, color)
defer sdl.FreeSurface(surfaceMessege)
texture: ^sdl.Texture = sdl.CreateTextureFromSurface(app.renderer, surfaceMessege)
defer sdl.DestroyTexture(texture)
textRect: sdl.Rect = {x, y, surfaceMessege.w, surfaceMessege.h}
sdl.RenderCopy(app.renderer, texture, nil, &textRect)
}
prepareScene :: proc() {
sdl.SetRenderDrawColor(app.renderer, state.bg.r, state.bg.g, state.bg.b, state.bg.a)
sdl.RenderClear(app.renderer)
}
presentScene :: proc() {
sdl.RenderPresent(app.renderer)
}