set up clay ui + move gold rendering to clay
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package game
|
||||
|
||||
import clay "../clay-odin"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
ui_memory: [^]u8
|
||||
ui_arena: clay.Arena
|
||||
ui_render_commands: clay.ClayArray(clay.RenderCommand)
|
||||
|
||||
ui_error_handler :: proc "c" (data: clay.ErrorData) {
|
||||
_ = data
|
||||
}
|
||||
|
||||
init_ui :: proc() {
|
||||
ui_register_font()
|
||||
|
||||
min_size := clay.MinMemorySize()
|
||||
ui_memory = make([^]u8, min_size)
|
||||
ui_arena = clay.CreateArenaWithCapacityAndMemory(uint(min_size), ui_memory)
|
||||
clay.Initialize(ui_arena, {f32(SCREEN_W), f32(SCREEN_H)}, {handler = ui_error_handler})
|
||||
clay.SetMeasureTextFunction(measure_text, nil)
|
||||
|
||||
}
|
||||
|
||||
destroy_ui :: proc() {
|
||||
free(ui_memory)
|
||||
}
|
||||
|
||||
ui_prepare_frame :: proc(world: ^World, dt: f32) {
|
||||
mouse := rl.GetMousePosition()
|
||||
clay.SetLayoutDimensions({f32(SCREEN_W), f32(SCREEN_H)})
|
||||
clay.SetPointerState({mouse.x, mouse.y}, rl.IsMouseButtonDown(.LEFT))
|
||||
clay.UpdateScrollContainers(false, {}, dt)
|
||||
|
||||
clay.BeginLayout()
|
||||
build_hud(world)
|
||||
ui_render_commands = clay.EndLayout(dt)
|
||||
}
|
||||
|
||||
render_ui :: proc() {
|
||||
clay_raylib_render(&ui_render_commands)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user