it's working on web and in window, waow

This commit is contained in:
Krzosa Karol
2025-01-22 11:08:16 +01:00
parent 802141a234
commit e54265fcac
24 changed files with 3320 additions and 1957 deletions

View File

@@ -9,6 +9,7 @@ gb f32 wasm_time;
gb f32 wasm_last_time;
gb app_frame_t wasm_frame;
gb u64 wasm_frame_counter;
gb u64 wasm_event_ids;
typedef struct wasm_cached_t wasm_cached_t;
struct wasm_cached_t {
@@ -23,6 +24,7 @@ fn void app_init(f32 dpr);
fn void wasm_add_event(app_event_t event) {
app_event_t *ev = ma_push_type(tcx.temp, app_event_t);
*ev = event;
ev->id = ++wasm_event_ids;
ev->alt = wasm_cached.alt;
ev->ctrl = wasm_cached.ctrl;
ev->shift = wasm_cached.shift;
@@ -75,7 +77,7 @@ fn_wasm_export void wasm_mouse_wheel(f32 x, f32 y, f32 delta_x, f32 delta_y, f32
wasm_set_cached_buttons(ctrl, shift, alt);
wasm_add_event((app_event_t){
.kind = app_event_kind_mouse_wheel,
.mouse_wheel_delta = {delta_x, delta_y, delta_z},
.mouse_wheel_delta = {delta_x, -delta_y, delta_z},
});
}
@@ -140,15 +142,7 @@ fn_wasm_export b32 wasm_update(f64 time, f32 width, f32 height, f32 dpr) {
return animating;
}
fn_wasm_export void wasm_init(void) {
fn_wasm_export void wasm_init(f32 dpr) {
core_init();
app_init(1.0); //@todo: dpr
app_init(dpr);
}
fn f32 app_get_anim_time(void) {
return wasm_time / 1000.0;
}
fn f32 app_get_anim_delta_time(void) {
return wasm_delta_time / 1000.0;
}