sketch out os api, binary stream writer in js, app sleep when no animation, local and universal time

This commit is contained in:
krzosa
2025-01-04 11:03:36 +01:00
parent 6f795b7ea6
commit dcd1266477
13 changed files with 316 additions and 87 deletions

View File

@@ -36,8 +36,6 @@ while (true) {
}
*/
fn_wasm_import f64 wasm_get_milliseconds(void);
gb_wasm_export char wasm_temp_buff1[128] = {[127] = 0x13};
gb_wasm_export i32 wasm_temp_buff1_len = 127;
gb_wasm_export char wasm_temp_buff2[128] = {[127] = 0x13};
@@ -47,7 +45,6 @@ gb f64 wasm_dpr;
gb f64 wasm_delta_time;
gb f64 wasm_time;
gb f64 wasm_last_time;
gb f64 wasm_app_init_time;
gb app_event_list_t wasm_event_list;
typedef struct wasm_cached_t wasm_cached_t;
@@ -56,7 +53,7 @@ struct wasm_cached_t {
b8 ctrl, alt, meta, shift;
} wasm_cached;
fn void app_update(app_event_list_t eventswasm_event_list);
fn b32 app_update(app_event_list_t);
fn void app_init(void);
fn void wasm_add_event(app_event_t event) {
@@ -179,12 +176,8 @@ fn_wasm_export void wasm_key_up(char *key, b32 ctrl, b32 shift, b32 alt, b32 met
}
}
fn f64 wasm_seconds_now(void) {
return wasm_get_milliseconds() / 1000.0;
}
fn_wasm_export void wasm_update(f64 width, f64 height, f64 dpr) {
wasm_time = wasm_seconds_now();
fn_wasm_export void wasm_update(f64 time, f64 width, f64 height, f64 dpr) {
wasm_time = time;
wasm_delta_time = wasm_time - wasm_last_time;
v2f64_t window_size = (v2f64_t){width / dpr, height / dpr};
@@ -216,13 +209,12 @@ fn_wasm_export void wasm_update(f64 width, f64 height, f64 dpr) {
fn_wasm_export void wasm_init(void) {
core_init();
app_init();
wasm_app_init_time = wasm_seconds_now();
}
fn f64 app_get_anim_time(void) {
return wasm_time;
return wasm_time / 1000.0;
}
fn f64 app_get_anim_delta_time(void) {
return wasm_delta_time;
return wasm_delta_time / 1000.0;
}