Fixed hot-reload for sokol

This commit is contained in:
2024-05-26 13:33:54 -04:00
parent 424587e6d1
commit 469fa5f8ec
4 changed files with 28 additions and 157 deletions

View File

@ -381,12 +381,34 @@ reload :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem,
transient = transient_mem
files_buffer = files_buffer_mem
context.allocator = persistent_allocator()
context.allocator = transient_allocator()
context.temp_allocator = transient_allocator()
Memory_App.state = get_state()
using state
sokol_context = context
Sokol:
{
desc_app := sokol_app.DescReload {
init_cb = sokol_app_init_callback,
frame_cb = sokol_app_frame_callback,
cleanup_cb = sokol_app_cleanup_callback,
event_cb = sokol_app_event_callback,
logger = { sokol_app_log_callback, nil },
allocator = { sokol_app_alloc, sokol_app_free, nil },
}
sokol_app.client_reload( desc_app )
desc_gfx := sokol_gfx.DescReload {
allocator = { sokol_gfx_alloc, sokol_gfx_free, nil },
logger = { sokol_gfx_log_callback, nil },
}
sokol_gfx.client_reload( desc_gfx )
}
// Procedure Addresses are not preserved on hot-reload. They must be restored for persistent data.
// The only way to alleviate this is to either do custom handles to allocators
// Or as done below, correct containers using allocators on reload.

View File

@ -7,8 +7,11 @@ render :: proc()
{
state := get_state(); using state
do_nothing : bool
do_nothing = false
// Clear Demo
if false
if true
{
green_value := debug.gfx_clear_demo_pass_action.colors[0].clear_value.g + 0.01
debug.gfx_clear_demo_pass_action.colors[0].clear_value.g = green_value > 1.0 ? 0.0 : green_value