summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOmniscient <omniscient.oce@gmail.com>2024-03-05 21:27:34 +1100
committerOmniscient <omniscient.oce@gmail.com>2024-03-05 21:27:34 +1100
commit3854bef8b853a369c4fc3a39abff5e2e9cd77625 (patch)
treee5836d1917a05932797b9652f568ccd1abe7aa14 /src
parent501c44488fb8918efb5f72b8c42690e8197aad31 (diff)
why is it crashing on file loading now?
Diffstat (limited to 'src')
-rw-r--r--src/platform/file.c6
-rw-r--r--src/renderer/render.h1
-rw-r--r--src/resources/loaders.h3
-rw-r--r--src/resources/obj.c4
-rw-r--r--src/std/str.h7
5 files changed, 16 insertions, 5 deletions
diff --git a/src/platform/file.c b/src/platform/file.c
index 44aa9d0..4eeee46 100644
--- a/src/platform/file.c
+++ b/src/platform/file.c
@@ -12,6 +12,7 @@
const char *string_from_file(const char *path) {
FILE *f = fopen(path, "rb");
+ printf("Hello\n");
if (f == NULL) {
ERROR("Error reading file: %s. errno: %d", path, errno);
return NULL;
@@ -20,6 +21,7 @@ const char *string_from_file(const char *path) {
ERROR("Error reading file: %s. errno: %d", path, errno);
return NULL;
}
+ printf("Hello2\n");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
rewind(f);
@@ -29,6 +31,8 @@ const char *string_from_file(const char *path) {
fclose(f);
string[fsize] = '\0';
+ printf("Hello3\n");
+ printf("Hello %s\n", string);
return string;
}
@@ -60,4 +64,4 @@ str8_opt str8_from_file(arena *a, str8 path) {
result.has_value = true;
return result;
-} \ No newline at end of file
+}
diff --git a/src/renderer/render.h b/src/renderer/render.h
index c4e0dd6..d1de515 100644
--- a/src/renderer/render.h
+++ b/src/renderer/render.h
@@ -1,6 +1,7 @@
#pragma once
#include "render_types.h"
+#include "loaders.h"
// --- Lifecycle
/** @brief initialise the render system frontend */
diff --git a/src/resources/loaders.h b/src/resources/loaders.h
index ba38ec4..8904655 100644
--- a/src/resources/loaders.h
+++ b/src/resources/loaders.h
@@ -3,7 +3,6 @@
#include "defines.h"
struct core;
-typedef u32 model_handle;
model_handle model_load_obj(struct core *core, const char *path, bool invert_texture_y);
-model_handle model_load_gltf(struct core *core, const char *path, bool invert_texture_y); \ No newline at end of file
+model_handle model_load_gltf(struct core *core, const char *path, bool invert_texture_y);
diff --git a/src/resources/obj.c b/src/resources/obj.c
index 9e12f79..05aa96e 100644
--- a/src/resources/obj.c
+++ b/src/resources/obj.c
@@ -36,7 +36,9 @@ bool load_material_lib(const char *path, material_darray *materials);
bool model_load_obj_str(const char *file_string, model *out_model, bool invert_textures_y);
model_handle model_load_obj(core *core, const char *path, bool invert_textures_y) {
+ printf("Path %s\n", path);
const char *file_string = string_from_file(path);
+ printf("Loaded file %s\n", file_string);
model model;
bool success = model_load_obj_str(file_string, &model, invert_textures_y);
@@ -89,7 +91,7 @@ bool model_load_obj_str(const char *file_string, model *out_model, bool invert_t
} else {
// read the first word of the line
int res = sscanf(pch, "%s %n", line_header, &offset);
- // printf("header: %s, offset : %d res: %d\n",line_header, offset, res);
+ /* printf("header: %s, offset : %d res: %d\n",line_header, offset, res); */
if (res != 1) {
break;
}
diff --git a/src/std/str.h b/src/std/str.h
index f6f8820..9f96430 100644
--- a/src/std/str.h
+++ b/src/std/str.h
@@ -70,4 +70,9 @@ str8 str8_concat(arena* a, str8 left, str8 right);
static inline bool str8_is_null_term(str8 a) {
return a.buf[a.len] == 0; // This doesn't seem safe. YOLO
-} \ No newline at end of file
+}
+
+// TODO: move or delete this and replace with handling using our internal type
+static void skip_space(char *p) {
+ while (isspace((unsigned char)*p)) ++p;
+}