minor tweaks
This commit is contained in:
parent
0a1761627b
commit
cdb0d2bf58
@ -130,7 +130,6 @@ void app_entry_point(void)
|
||||
user_startup(&window);
|
||||
playback_startup();
|
||||
|
||||
|
||||
/* Show window */
|
||||
sys_window_show(&window);
|
||||
|
||||
|
||||
132
src/atomic.h
132
src/atomic.h
@ -1,115 +1,35 @@
|
||||
#ifndef ATOMICS_H
|
||||
#define ATOMICS_H
|
||||
#ifndef ATOMIC_H
|
||||
#define ATOMIC_H
|
||||
|
||||
#if OS_WINDOWS
|
||||
|
||||
/* atomic_i32 */
|
||||
FORCE_INLINE i32 atomic_i32_eval(struct atomic_i32 *x) { return _InterlockedExchangeAdd((volatile long *)&x->_v, 0); }
|
||||
FORCE_INLINE i32 atomic_i32_inc_eval(struct atomic_i32 *x) { return _InterlockedIncrement((volatile long *)&x->_v); }
|
||||
FORCE_INLINE i32 atomic_i32_dec_eval(struct atomic_i32 *x) { return _InterlockedDecrement((volatile long *)&x->_v); }
|
||||
FORCE_INLINE i32 atomic_i32_eval_add(struct atomic_i32 *x, i32 a) { return _InterlockedExchangeAdd((volatile long *)&x->_v, a); }
|
||||
FORCE_INLINE i32 atomic_i32_eval_exchange(struct atomic_i32 *x, i32 e) { return _InterlockedExchange((volatile long *)&x->_v, e); }
|
||||
FORCE_INLINE i32 atomic_i32_eval_compare_exchange(struct atomic_i32 *x, i32 c, i32 e) { return _InterlockedCompareExchange((volatile long *)&x->_v, e, c); }
|
||||
|
||||
FORCE_INLINE i32 atomic_i32_eval(struct atomic_i32 *x)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long *)&x->_v, 0);
|
||||
}
|
||||
FORCE_INLINE i32 atomic_i32_inc_eval(struct atomic_i32 *x)
|
||||
{
|
||||
return _InterlockedIncrement((volatile long *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE i32 atomic_i32_dec_eval(struct atomic_i32 *x)
|
||||
{
|
||||
return _InterlockedDecrement((volatile long *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE i32 atomic_i32_eval_add(struct atomic_i32 *x, i32 a)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long *)&x->_v, a);
|
||||
}
|
||||
FORCE_INLINE i32 atomic_i32_eval_exchange(struct atomic_i32 *x, i32 e)
|
||||
{
|
||||
return _InterlockedExchange((volatile long *)&x->_v, e);
|
||||
}
|
||||
FORCE_INLINE i32 atomic_i32_eval_compare_exchange(struct atomic_i32 *x, i32 c, i32 e)
|
||||
{
|
||||
return _InterlockedCompareExchange((volatile long *)&x->_v, e, c);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_eval(struct atomic_i64 *x) { return _InterlockedExchangeAdd64(&x->_v, 0); }
|
||||
FORCE_INLINE i64 atomic_i64_inc_eval(struct atomic_i64 *x) { return _InterlockedIncrement64(&x->_v); }
|
||||
FORCE_INLINE i64 atomic_i64_dec_eval(struct atomic_i64 *x) { return _InterlockedDecrement64(&x->_v); }
|
||||
FORCE_INLINE i64 atomic_i64_eval_add(struct atomic_i64 *x, i64 a) { return _InterlockedExchangeAdd64(&x->_v, a); }
|
||||
FORCE_INLINE i64 atomic_i64_eval_exchange(struct atomic_i64 *x, i64 e) { return _InterlockedExchange64(&x->_v, e); }
|
||||
FORCE_INLINE i64 atomic_i64_eval_compare_exchange(struct atomic_i64 *x, i64 c, i64 e) { return _InterlockedCompareExchange64(&x->_v, e, c); }
|
||||
|
||||
/* atomic_u32 */
|
||||
FORCE_INLINE u32 atomic_u32_eval(struct atomic_u32 *x) { return _InterlockedExchangeAdd((volatile long *)&x->_v, 0); }
|
||||
FORCE_INLINE u32 atomic_u32_inc_eval(struct atomic_u32 *x) { return _InterlockedIncrement((volatile long *)&x->_v); }
|
||||
FORCE_INLINE u32 atomic_u32_dec_eval(struct atomic_u32 *x) { return _InterlockedDecrement((volatile long *)&x->_v); }
|
||||
FORCE_INLINE u32 atomic_u32_eval_add(struct atomic_u32 *x, u32 a) { return _InterlockedExchangeAdd((volatile long *)&x->_v, a); }
|
||||
FORCE_INLINE u32 atomic_u32_eval_exchange(struct atomic_u32 *x, u32 e) { return _InterlockedExchange((volatile long *)&x->_v, e); }
|
||||
FORCE_INLINE u32 atomic_u32_eval_compare_exchange(struct atomic_u32 *x, u32 c, u32 e) { return _InterlockedCompareExchange((volatile long *)&x->_v, e, c); }
|
||||
|
||||
FORCE_INLINE u32 atomic_u32_eval(struct atomic_u32 *x)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long *)&x->_v, 0);
|
||||
}
|
||||
FORCE_INLINE u32 atomic_u32_inc_eval(struct atomic_u32 *x)
|
||||
{
|
||||
return _InterlockedIncrement((volatile long *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE u32 atomic_u32_dec_eval(struct atomic_u32 *x)
|
||||
{
|
||||
return _InterlockedDecrement((volatile long *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE u32 atomic_u32_eval_add(struct atomic_u32 *x, u32 a)
|
||||
{
|
||||
return _InterlockedExchangeAdd((volatile long *)&x->_v, a);
|
||||
}
|
||||
FORCE_INLINE u32 atomic_u32_eval_exchange(struct atomic_u32 *x, u32 e)
|
||||
{
|
||||
return _InterlockedExchange((volatile long *)&x->_v, e);
|
||||
}
|
||||
FORCE_INLINE u32 atomic_u32_eval_compare_exchange(struct atomic_u32 *x, u32 c, u32 e)
|
||||
{
|
||||
return _InterlockedCompareExchange((volatile long *)&x->_v, e, c);
|
||||
}
|
||||
|
||||
/* atomic_i64 */
|
||||
|
||||
FORCE_INLINE i64 atomic_i64_eval(struct atomic_i64 *x)
|
||||
{
|
||||
return _InterlockedExchangeAdd64(&x->_v, 0);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_inc_eval(struct atomic_i64 *x)
|
||||
{
|
||||
return _InterlockedIncrement64(&x->_v);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_dec_eval(struct atomic_i64 *x)
|
||||
{
|
||||
return _InterlockedDecrement64(&x->_v);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_eval_add(struct atomic_i64 *x, i64 a)
|
||||
{
|
||||
return _InterlockedExchangeAdd64(&x->_v, a);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_eval_exchange(struct atomic_i64 *x, i64 e)
|
||||
{
|
||||
return _InterlockedExchange64(&x->_v, e);
|
||||
}
|
||||
FORCE_INLINE i64 atomic_i64_eval_compare_exchange(struct atomic_i64 *x, i64 c, i64 e)
|
||||
{
|
||||
return _InterlockedCompareExchange64(&x->_v, e, c);
|
||||
}
|
||||
|
||||
/* atomic_u64 */
|
||||
|
||||
FORCE_INLINE u64 atomic_u64_eval(struct atomic_u64 *x)
|
||||
{
|
||||
return _InterlockedExchangeAdd64((volatile i64 *)&x->_v, 0);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_inc_eval(struct atomic_u64 *x)
|
||||
{
|
||||
return _InterlockedIncrement64((volatile i64 *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_dec_eval(struct atomic_u64 *x)
|
||||
{
|
||||
return _InterlockedDecrement64((volatile i64 *)&x->_v);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_eval_add(struct atomic_u64 *x, u64 a)
|
||||
{
|
||||
return _InterlockedExchangeAdd64((volatile i64 *)&x->_v, a);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_eval_exchange(struct atomic_u64 *x, u64 e)
|
||||
{
|
||||
return _InterlockedExchange64((volatile i64 *)&x->_v, e);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_eval_compare_exchange(struct atomic_u64 *x, u64 c, u64 e)
|
||||
{
|
||||
return _InterlockedCompareExchange64((volatile i64 *)&x->_v, e, c);
|
||||
}
|
||||
FORCE_INLINE u64 atomic_u64_eval(struct atomic_u64 *x) { return _InterlockedExchangeAdd64((volatile i64 *)&x->_v, 0); }
|
||||
FORCE_INLINE u64 atomic_u64_inc_eval(struct atomic_u64 *x) { return _InterlockedIncrement64((volatile i64 *)&x->_v); }
|
||||
FORCE_INLINE u64 atomic_u64_dec_eval(struct atomic_u64 *x) { return _InterlockedDecrement64((volatile i64 *)&x->_v); }
|
||||
FORCE_INLINE u64 atomic_u64_eval_add(struct atomic_u64 *x, u64 a) { return _InterlockedExchangeAdd64((volatile i64 *)&x->_v, a); }
|
||||
FORCE_INLINE u64 atomic_u64_eval_exchange(struct atomic_u64 *x, u64 e) { return _InterlockedExchange64((volatile i64 *)&x->_v, e); }
|
||||
FORCE_INLINE u64 atomic_u64_eval_compare_exchange(struct atomic_u64 *x, u64 c, u64 e) { return _InterlockedCompareExchange64((volatile i64 *)&x->_v, e, c); }
|
||||
|
||||
#else
|
||||
# error "Atomics not implemented"
|
||||
|
||||
@ -296,14 +296,14 @@ struct atomic_i32 {
|
||||
volatile i32 _v;
|
||||
};
|
||||
|
||||
struct atomic_u32 {
|
||||
volatile u32 _v;
|
||||
};
|
||||
|
||||
struct atomic_i64 {
|
||||
volatile i64 _v;
|
||||
};
|
||||
|
||||
struct atomic_u32 {
|
||||
volatile u32 _v;
|
||||
};
|
||||
|
||||
struct atomic_u64 {
|
||||
volatile u64 _v;
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
* system. */
|
||||
#define RESOURCES_EMBEDDED !(DEVELOPER)
|
||||
|
||||
#define DEFAULT_CAMERA_WIDTH (6)
|
||||
#define DEFAULT_CAMERA_WIDTH (7)
|
||||
#define DEFAULT_CAMERA_HEIGHT (DEFAULT_CAMERA_WIDTH / (16.0 / 9.0))
|
||||
|
||||
#define PIXELS_PER_UNIT 256
|
||||
|
||||
@ -97,9 +97,9 @@ struct entity {
|
||||
struct xform camera_quad_xform;
|
||||
f32 camera_lerp; /* Rate at which camera xform approaches target xform */
|
||||
|
||||
u32 camera_lerp_gen;
|
||||
u32 camera_lerp_continuity_gen;
|
||||
struct xform camera_rel_xform_target; /* Calculated from camera_follow */
|
||||
u32 camera_applied_lerp_gen_plus_one; /* Calculated */
|
||||
u32 camera_applied_lerp_continuity_gen_plus_one; /* Calculated */
|
||||
};
|
||||
|
||||
struct entity_array {
|
||||
|
||||
21
src/font.c
21
src/font.c
@ -92,7 +92,7 @@ INTERNAL void font_load_asset_task(void *vparams)
|
||||
|
||||
ASSERT(string_ends_with(path, STR(".ttf")));
|
||||
if (!resource_exists(path)) {
|
||||
/* TODO: Load baked font instead of panicking */
|
||||
/* FIME: Load baked font instead of panicking */
|
||||
sys_panic(string_format(scratch.arena,
|
||||
STR("Font \"%F\" not found"),
|
||||
FMT_STR(path)));
|
||||
@ -126,6 +126,13 @@ INTERNAL void font_load_asset_task(void *vparams)
|
||||
font->glyphs_count = result.glyphs_count;
|
||||
font->point_size = point_size;
|
||||
|
||||
/* FIXME: Load banked font instead of panicking */
|
||||
if (font->glyphs_count <= 0) {
|
||||
sys_panic(string_format(scratch.arena,
|
||||
STR("Parsed 0 glyphs from font \"%F\"!"),
|
||||
FMT_STR(path)));
|
||||
}
|
||||
|
||||
/* Copy glyphs from decode result */
|
||||
MEMCPY(font->glyphs, result.glyphs, sizeof(*font->glyphs) * result.glyphs_count);
|
||||
|
||||
@ -209,12 +216,12 @@ struct font *font_load(struct string path, f32 point_size)
|
||||
|
||||
struct font_glyph *font_get_glyph(struct font *font, u8 c)
|
||||
{
|
||||
struct font_glyph *g;
|
||||
/* Need to add a check here for c < LOOKUP_TABLE_SIZE if range is ever increased */
|
||||
CT_ASSERT(sizeof(c) == 1 && LOOKUP_TABLE_SIZE >= 256);
|
||||
|
||||
u16 index = font->lookup[c];
|
||||
if (index < LOOKUP_TABLE_SIZE) {
|
||||
g = &font->glyphs[index];
|
||||
} else {
|
||||
g = &font->glyphs[0];
|
||||
if (index < font->glyphs_count) {
|
||||
return &font->glyphs[index];
|
||||
}
|
||||
return g;
|
||||
return &font->glyphs[0];
|
||||
}
|
||||
|
||||
@ -495,14 +495,14 @@ INTERNAL void game_update(void)
|
||||
}
|
||||
|
||||
/* Lerp camera */
|
||||
if (ent->camera_applied_lerp_gen_plus_one == ent->camera_lerp_gen + 1) {
|
||||
if (ent->camera_applied_lerp_continuity_gen_plus_one == ent->camera_lerp_continuity_gen + 1) {
|
||||
f32 t = 1 - math_pow(2.f, -20.f * (f32)L.world.dt);
|
||||
ent->rel_xform = xform_lerp(ent->rel_xform, ent->camera_rel_xform_target, t);
|
||||
} else {
|
||||
/* Skip lerp */
|
||||
ent->rel_xform = ent->camera_rel_xform_target;
|
||||
}
|
||||
ent->camera_applied_lerp_gen_plus_one = ent->camera_lerp_gen + 1;
|
||||
ent->camera_applied_lerp_continuity_gen_plus_one = ent->camera_lerp_continuity_gen + 1;
|
||||
|
||||
/* Recalculate xform tree */
|
||||
recalculate_world_xform_recurse(ent);
|
||||
|
||||
@ -40,7 +40,6 @@ struct string string_from_uint(struct arena *arena, u64 n, u32 base)
|
||||
/* Base too large */
|
||||
ASSERT(base <= (ARRAY_COUNT(INT_CHARS) - 1));
|
||||
|
||||
/* TODO: we can probably use a fixed buffer here rather than scratch */
|
||||
struct temp_arena scratch = scratch_begin(arena);
|
||||
|
||||
/* Build backwards text starting from least significant digit */
|
||||
|
||||
16
src/user.c
16
src/user.c
@ -591,21 +591,9 @@ INTERNAL void user_update(void)
|
||||
/* Zoom view */
|
||||
i32 input_zooms = L.bind_states[USER_BIND_KIND_ZOOM_IN].num_presses - L.bind_states[USER_BIND_KIND_ZOOM_OUT].num_presses;
|
||||
if (input_zooms != 0) {
|
||||
i32 dir = input_zooms >= 0 ? 1 : -1;
|
||||
u32 zooms_abs = input_zooms >= 0 ? input_zooms : -input_zooms;
|
||||
|
||||
/* Determine zoom */
|
||||
f32 zoom_rate = 2;
|
||||
f32 zoom = 1;
|
||||
for (u32 i = 0; i < zooms_abs; ++i) {
|
||||
if (dir > 0) {
|
||||
zoom *= zoom_rate;
|
||||
} else {
|
||||
zoom *= 1.0f / zoom_rate;
|
||||
}
|
||||
}
|
||||
|
||||
/* Zoom to cursor */
|
||||
f32 zoom_rate = 2;
|
||||
f32 zoom = math_pow(zoom_rate, input_zooms);
|
||||
struct v2 world_cursor = xform_invert_mul_v2(L.world_view, L.viewport_cursor);
|
||||
L.world_view = xform_translate(L.world_view, world_cursor);
|
||||
L.world_view = xform_scale(L.world_view, V2(zoom, zoom));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user