disable vsync again

efd/v1
Dominik Madarász 2022-10-17 18:28:18 +02:00
parent 0d58d5f315
commit 3f6235e8a4
3 changed files with 53 additions and 53 deletions

View File

@ -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,
});

View File

@ -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;

View File

@ -5,12 +5,12 @@
#include <emscripten.h>
#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);