summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/include/engine/engine.h2
-rw-r--r--src/core/src/loop.c24
2 files changed, 16 insertions, 10 deletions
diff --git a/src/core/include/engine/engine.h b/src/core/include/engine/engine.h
index 51228fb..0b1a540 100644
--- a/src/core/include/engine/engine.h
+++ b/src/core/include/engine/engine.h
@@ -49,7 +49,7 @@ void render_add_unit(RenderUnit* u);
void delay(uint64_t ms);
// file operations
-isize f_get_sz(FILE* f);
+usize f_get_sz(FILE* f);
#ifdef __cplusplus
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index 1c1ec52..076dc05 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -124,7 +124,7 @@ Platform* engine_init(const char* windowtitle, i32 windowWidth, i32 windowHeight
w = init_window_glfw(windowtitle, (ivec2){windowsize.x, windowsize.y}, flags);
// Dont forget to init the renderer
- init_render_opengl(w);
+ init_render_opengl(w, flags);
//{ /* Resource loading */
@@ -371,13 +371,13 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
printf(" FPS: %.1f"
"\tticks: %lu"
- "\tframetime: %luμs"
- "\trendertime: %luμs"
+ "\tframetime: %lu.%lums"
+ "\trendertime: %lu.%lums"
"\n"
, ((f64)(ticks - last_fps_ticks)) / ((f64)dt_measurement / 1000000.0)
, ticks
- , dt
- , rendertime_dt
+ , dt / 1000 , dt % 1000
+ , rendertime_dt / 1000 , rendertime_dt % 1000
);
last_fps_measurement = frame_end;
@@ -421,7 +421,7 @@ void engine_fps_max(Platform* p, u16 cap) {
p->fps_target = cap;
}
-isize f_get_sz(FILE* f) {
+usize f_get_sz(FILE* f) {
if (f == NULL) {
ERROR("File was null!");
return 0;
@@ -430,22 +430,28 @@ isize f_get_sz(FILE* f) {
const isize pos = ftell(f);
if (pos == -1) {
ERROR("Failed to determine file size (%d): %s", errno, strerror(errno));
+ return 0;
}
const i32 err = fseek(f, 0, SEEK_END);
if (err != 0) {
- if (err == ESPIPE) return 0;
- ERROR("Failed to determine file size!");
+ if (err == ESPIPE) {
+ ERROR("File is a pipe");
+ } else {
+ ERROR("Failed to determine file size!");
+ }
+ return 0;
}
const isize size = ftell(f);
if (size == -1) {
ERROR("Failed to determine file size (%d): %s", errno, strerror(errno));
+ return 0;
}
// Reset the position to the position prior to calling f_get_sz
fseek(f, pos, SEEK_SET);
- return size;
+ return (usize)size;
}