7KBG6K7U5DHR7HDFXS2DPJVDCPI4RDATU55KNDLBFSTWSVZPU4QQC
}
static uint32_t _render_white_image(void) {
static bool init = false;
static struct Image image;
if(!init) {
init = true;
uint8_t * data = alias_stack_allocation(16 * 16 * 3, 1);
alias_memory_set(data, 16 * 16 * 3, 255, 16 * 16 * 3);
_image_upload_2d(&image, 16, 16, 3, data, true);
}
return image.gl.image;
static float _physics_speed = 1.0f;
static float _physics_time;
static float _physics_frame_time;
static void _update_physics(void) {
const float timestep = 1.0f / 60.0f;
static float p_time = 0.0f;
static float s_time = 0.0f;
float time = _physics_time;
_physics_time = (float)((double)uv_hrtime() / 1000000000.0);
_physics_frame_time = _physics_time - time;
s_time += _physics_frame_time * _physics_speed;
if(p_time >= s_time) {
alias_transform_update2d_serial(engine_ecs(), engine_ecs_transform());
}
while(p_time < s_time) {
alias_physics_update2d_serial_pre_transform(engine_ecs(), engine_ecs_physics_2d(), timestep);
alias_transform_update2d_serial(engine_ecs(), engine_ecs_transform());
alias_physics_update2d_serial_post_transform(engine_ecs(), engine_ecs_physics_2d(), timestep);
p_time += timestep;
}
}
void _image_load(struct Image *image, const char *path) {
int width, height, channels;
uint8_t *data = stbi_load(path, &width, &height, &channels, 0);
if(data == NULL) {
engine_warning("stb_load: loading %s failed.", path);
return;
}
if(data == NULL) {
engine_warning("stb_load: loading %s failed.", path);
return;
}
if(channels != 3 && channels != 4) {
engine_warning("stb_load: invalid channel value %i", channels);
stbi_image_free(data);
return;
}
engine_trace("stb_load: loaded %s", path);
_image_upload_2d(image, width, height, channels, data, true);
stbi_image_free(data);
}