From 8130faa6adb2a7ef113cbc67743d6b363ef5ef2d Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 22 May 2024 03:44:14 -0400 Subject: [PATCH] got the sokol_app library starting up and ticking! Now I just need to get the events and rendering and fonts and... all hooked up --- code/sectr/app/state.odin | 1 - code/sectr/engine/client_api_sokol.odin | 9 +++- .../engine/client_api_sokol_callbacks.odin | 46 ------------------- 3 files changed, 8 insertions(+), 48 deletions(-) diff --git a/code/sectr/app/state.odin b/code/sectr/app/state.odin index 6c5ce8a..f2287b6 100644 --- a/code/sectr/app/state.odin +++ b/code/sectr/app/state.odin @@ -250,7 +250,6 @@ State :: struct { // The camera is considered the "context" for coodrinate space operations in rendering cam_context : Camera, - // sokol_relay : SokolRelay, sokol_context : runtime.Context, } diff --git a/code/sectr/engine/client_api_sokol.odin b/code/sectr/engine/client_api_sokol.odin index a42c151..e3abf52 100644 --- a/code/sectr/engine/client_api_sokol.odin +++ b/code/sectr/engine/client_api_sokol.odin @@ -170,6 +170,13 @@ startup :: proc( prof : ^SpallProfiler, persistent_mem, frame_mem, transient_mem sokol_app.pre_client_init(desc) sokol_app.client_init() + // if config.engine_refresh_hz == 0 { + // config.engine_refresh_hz = sokol_app.frame_duration() + // } + if config.engine_refresh_hz == 0 { + config.engine_refresh_hz = 165 + } + // rl.Odin_SetMalloc( RL_MALLOC ) // rl.SetConfigFlags( { @@ -440,7 +447,7 @@ tick :: proc( host_delta_time : f64, host_delta_ns : Duration ) -> b32 sokol_app.post_client_frame() profile_end() } - return should_close + return ! should_close } @export diff --git a/code/sectr/engine/client_api_sokol_callbacks.odin b/code/sectr/engine/client_api_sokol_callbacks.odin index 7529bc5..57dabad 100644 --- a/code/sectr/engine/client_api_sokol_callbacks.odin +++ b/code/sectr/engine/client_api_sokol_callbacks.odin @@ -5,27 +5,9 @@ import str "core:strings" import sokol_app "thirdparty:sokol/app" -// SokolLogEntry :: struct { -// tag: cstring, -// log_level: u32, -// log_item_id: u32, -// message_or_null: cstring, -// line_nr: u32, -// filename_or_null : cstring, -// } - -// SokolRelay :: struct { -// logs : StackFixed(SokolLogEntry, 512), -// } - -// sokol_relay :: #force_inline proc "contextless" () -> ^SokolRelay { -// return & get_state().sokol_relay -// } - sokol_app_init_callback :: proc "c" () { context = get_state().sokol_context log("sokol_app: Confirmed initialization") - // stack_push_contextless( & sokol_relay().logs, { "", 3, 0, "sokol_app: Confirmed initialization", 29, #file }) } // This is being filled in but we're directly controlling the lifetime of sokol_app's execution. @@ -33,13 +15,11 @@ sokol_app_init_callback :: proc "c" () { sokol_app_frame_callback :: proc "c" () { context = get_state().sokol_context log("sokol_app: SHOULD NOT HAVE CALLED THE FRAME CALLABCK") - // stack_push_contextless( & sokol_relay().logs, { "", 3, 0, "sokol_app: SHOULD NOT HAVE CALLED THE FRAME CALLBACK", 29, #file }) } sokol_app_cleanup_callback :: proc "c" () { context = get_state().sokol_context log("sokol_app: Confirmed cleanup") - // stack_push_contextless( & sokol_relay().logs, { "", 3, 0, "sokol_app: Confirmed cleanup", 29, #file }) } sokol_app_alloc :: proc "c" ( size : u64, user_data : rawptr ) -> rawptr { @@ -82,34 +62,8 @@ sokol_app_log_callback :: proc "c" ( } logf( "%-80s %v : %s::%s", cloned_msg, cloned_fname, str.clone_from_cstring(tag), level = odin_level ) - // push( & sokol_relay().logs, {tag, log_level, log_item_id, message_or_null, line_nr, filename_or_null, user_data }) } -// sokol_app_relay_update :: proc() -// { -// logs := & sokol_relay().logs -// for ; logs.idx != 0; pop( logs ) { -// odin_level : LogLevel -// switch log_level { -// case 0: odin_level = .Fatal -// case 1: odin_level = .Error -// case 2: odin_level = .Warning -// case 3: odin_level = .Info -// } - -// cloned_msg : string = "" -// if message != nil { -// cloned_msg = str.clone_from_cstring(message, context.temp_allocator) -// } -// cloned_fname : string = "" -// if filename_or_null { -// cloned_fname = str.clone_from_cstring(filename_or_null, context.temp_allocator) -// } - -// logf( "%-80s %v : %s::%s", cloned_msg, cloned_fname, str.clone_from_cstring(tag), level = odin_level ) -// } -// } - sokol_app_event_callback :: proc "c" (event : ^sokol_app.Event) { }