From 3f6235e8a477b17264bb0eca508e10064d2aef79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 17 Oct 2022 18:28:18 +0200 Subject: [PATCH] disable vsync again --- code/foundation/src/debug/debug_draw.c | 6 +- code/foundation/src/models/components.h | 20 +++---- code/foundation/src/platform/arch.h | 80 ++++++++++++------------- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/code/foundation/src/debug/debug_draw.c b/code/foundation/src/debug/debug_draw.c index 38ecd96..a6b4982 100644 --- a/code/foundation/src/debug/debug_draw.c +++ b/code/foundation/src/debug/debug_draw.c @@ -36,7 +36,7 @@ void debug_push_line(debug_v2 a, debug_v2 b, int32_t color) { debug_push_entry((debug_draw_entry){ .kind = DDRAW_LINE, .color = color, - + .a = a, .b = b, }); @@ -46,7 +46,7 @@ void debug_push_circle(debug_v2 pos, float radius, int32_t color) { debug_push_entry((debug_draw_entry){ .kind = DDRAW_CIRCLE, .color = color, - + .pos = pos, .radius = radius, }); @@ -56,7 +56,7 @@ void debug_push_rect(debug_v2 bmin, debug_v2 bmax, int32_t color) { debug_push_entry((debug_draw_entry){ .kind = DDRAW_RECT, .color = color, - + .bmin = bmin, .bmax = bmax, }); diff --git a/code/foundation/src/models/components.h b/code/foundation/src/models/components.h index 8f61f83..1e7726a 100644 --- a/code/foundation/src/models/components.h +++ b/code/foundation/src/models/components.h @@ -3,17 +3,17 @@ #include "models/assets.h" #define ecs_get_mut_ex(world, entity, T) \ - (ECS_CAST(T*, world_component_cached(world, entity, ecs_id(T)))) +(ECS_CAST(T*, world_component_cached(world, entity, ecs_id(T)))) #define ecs_get_if(world, entity, T) \ - (world_entity_valid(entity) ? ecs_get(world, entity, T) : NULL) +(world_entity_valid(entity) ? ecs_get(world, entity, T) : NULL) #define ecs_get_mut_if_ex(world, entity, component) \ - (ecs_get_if(world, entity, component) ? ecs_get_mut_ex(world, entity, component) : NULL) +(ecs_get_if(world, entity, component) ? ecs_get_mut_ex(world, entity, component) : NULL) #ifndef ecs_get_mut_if #define ecs_get_mut_if(world, entity, component)\ - (ecs_get(world, entity, component) ? ecs_get_mut(world, entity, component) : NULL) +(ecs_get(world, entity, component) ? ecs_get_mut(world, entity, component) : NULL) #endif #define ITEMS_INVENTORY_SIZE 9 @@ -52,7 +52,7 @@ typedef struct { uint8_t is_blocked; ecs_entity_t pick_ent; ecs_entity_t sel_ent; - + // NOTE(zaklaus): inventory ecs_entity_t storage_ent; uint8_t storage_action; @@ -63,7 +63,7 @@ typedef struct { uint8_t swap_storage; uint8_t swap_from; uint8_t swap_to; - + // NOTE(zaklaus): build mode uint8_t num_placements; float placements_x[20]; @@ -80,7 +80,7 @@ typedef struct { typedef struct { float hp; float max_hp; - + //NOTE(zaklaus): Intentionally global, to allow for creative use of damage combos float pain_time; float heal_time; @@ -92,12 +92,12 @@ typedef struct { typedef struct { uint64_t seats[4]; - + float force; float heading; float steer; float wheel_base; - + float speed; float reverse_speed; uint8_t veh_kind; @@ -148,7 +148,7 @@ typedef struct { typedef struct { uint16_t asset; - + // progress bar uint8_t progress_active; float progress_value; diff --git a/code/foundation/src/platform/arch.h b/code/foundation/src/platform/arch.h index 19f459e..0330ac0 100644 --- a/code/foundation/src/platform/arch.h +++ b/code/foundation/src/platform/arch.h @@ -5,12 +5,12 @@ #include #ifdef ARCH_IMPL EM_JS(int, canvas_get_width, (), { - return canvas.width; -}); + return canvas.width; + }); EM_JS(int, canvas_get_height, (), { - return canvas.height; -}); + return canvas.height; + }); void UpdateDrawFrame(void) { reset_cached_time(); @@ -19,7 +19,7 @@ void UpdateDrawFrame(void) { game_update(); game_render(); } - + profiler_collate(); } #else @@ -43,42 +43,42 @@ void reset_cached_time(void) { } void game_run(void) { - #if !defined(PLATFORM_WEB) - while (game_is_running()) { - reset_cached_time(); - profile (PROF_MAIN_LOOP) { - game_input(); - game_update(); - game_render(); - } - - profiler_collate(); +#if !defined(PLATFORM_WEB) + while (game_is_running()) { + reset_cached_time(); + profile (PROF_MAIN_LOOP) { + game_input(); + game_update(); + game_render(); } - #else - emscripten_set_main_loop(UpdateDrawFrame, 0, 1); - #endif + + profiler_collate(); + } +#else + emscripten_set_main_loop(UpdateDrawFrame, 0, 1); +#endif } void platform_create_window(const char *title) { SetTraceLogLevel(LOG_ERROR); - - #if defined(PLATFORM_WEB) - screenWidth = (uint16_t)canvas_get_width(); - screenHeight = (uint16_t)canvas_get_height(); - #endif - - InitWindow(screenWidth, screenHeight, title); - uint32_t flags = /*FLAG_WINDOW_UNDECORATED|*/FLAG_WINDOW_MAXIMIZED|FLAG_WINDOW_RESIZABLE|FLAG_MSAA_4X_HINT; - #if !defined(PLATFORM_WEB) - flags |= FLAG_VSYNC_HINT; - #endif - SetWindowState(flags); - - #if !defined(PLATFORM_WEB) - screenWidth = (uint16_t)GetScreenWidth(); - screenHeight = (uint16_t)GetScreenHeight(); - #endif - // ToggleFullscreen(); - // SetTargetFPS(60.0); + +#if defined(PLATFORM_WEB) + screenWidth = (uint16_t)canvas_get_width(); + screenHeight = (uint16_t)canvas_get_height(); +#endif + + InitWindow(screenWidth, screenHeight, title); + uint32_t flags = /*FLAG_WINDOW_UNDECORATED|*/FLAG_WINDOW_MAXIMIZED|FLAG_WINDOW_RESIZABLE|FLAG_MSAA_4X_HINT; +#if !defined(PLATFORM_WEB) + //flags |= FLAG_VSYNC_HINT; +#endif + SetWindowState(flags); + +#if !defined(PLATFORM_WEB) + screenWidth = (uint16_t)GetScreenWidth(); + screenHeight = (uint16_t)GetScreenHeight(); +#endif + // ToggleFullscreen(); + // SetTargetFPS(60.0); } void platform_resize_window() { @@ -121,13 +121,13 @@ inline static void platform_input_update_input_frame(game_keystate_data data) { float mx = 0, my = 0; platform_get_block_realpos(&mx, &my); - + if (mx != last_blockpos_data.mx || my != last_blockpos_data.my){ last_blockpos_data.mx = mx; last_blockpos_data.my = my; game_action_send_blockpos(mx, my); } - + // NOTE(zaklaus): Test if there are any changes if (data.x != last_input_data.x) goto send_data; if (data.y != last_input_data.y) goto send_data; @@ -145,7 +145,7 @@ void platform_input_update_input_frame(game_keystate_data data) { if (data.deletion_mode != last_input_data.deletion_mode) goto send_data; if (zpl_memcompare(data.placements, last_input_data.placements, zpl_size_of(data.placements))) goto send_data; return; - + send_data: last_input_data = data; game_action_send_keystate(&data);