summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/models/obj/cube/cube.mtl3
-rw-r--r--assets/models/obj/cube/cube.obj4
-rw-r--r--src/core.c5
-rw-r--r--src/empty.c4
-rw-r--r--src/platform/file.c4
-rw-r--r--src/renderer/render.h2
-rw-r--r--src/renderer/render_types.h2
-rw-r--r--src/resources/obj.c17
-rw-r--r--src/std/str.h2
9 files changed, 17 insertions, 26 deletions
diff --git a/assets/models/obj/cube/cube.mtl b/assets/models/obj/cube/cube.mtl
index 83a0e8c..9a17b69 100644
--- a/assets/models/obj/cube/cube.mtl
+++ b/assets/models/obj/cube/cube.mtl
@@ -10,5 +10,4 @@ Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
-map_Kd container.jpg
-
+map_Kd models/obj/cube/container.jpg
diff --git a/assets/models/obj/cube/cube.obj b/assets/models/obj/cube/cube.obj
index db3bda6..430e5da 100644
--- a/assets/models/obj/cube/cube.obj
+++ b/assets/models/obj/cube/cube.obj
@@ -1,7 +1,7 @@
# cube.obj
#
-mtllib cube.mtl
+mtllib models/obj/cube/cube.mtl
o cube
v -0.500000 -0.500000 0.500000
@@ -44,4 +44,4 @@ f 2/1/5 8/2/5 4/3/5
f 4/3/5 8/2/5 6/4/5
s 6
f 7/1/6 1/2/6 5/3/6
-f 5/3/6 1/2/6 3/4/6 \ No newline at end of file
+f 5/3/6 1/2/6 3/4/6
diff --git a/src/core.c b/src/core.c
index affd8c8..024b2d7 100644
--- a/src/core.c
+++ b/src/core.c
@@ -45,8 +45,7 @@ core* core_bringup() {
}
*/
- // c->underworld.models = model_darray_new(10);
- // c->underworld.renderables = render_entity_darray_new(10);
+ c->models = model_darray_new(10);
return c;
-} \ No newline at end of file
+}
diff --git a/src/empty.c b/src/empty.c
index d58a94f..b40cc85 100644
--- a/src/empty.c
+++ b/src/empty.c
@@ -1,5 +1,3 @@
// For some reason on Mac we need an empty file so that 'ar' has something
// to run.
-int add(int a, int b) {
- return a + b;
-} \ No newline at end of file
+int add(int a, int b) { return a + b; } \ No newline at end of file
diff --git a/src/platform/file.c b/src/platform/file.c
index 4eeee46..ec9259a 100644
--- a/src/platform/file.c
+++ b/src/platform/file.c
@@ -12,7 +12,6 @@
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;
@@ -21,7 +20,6 @@ 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);
@@ -31,8 +29,6 @@ const char *string_from_file(const char *path) {
fclose(f);
string[fsize] = '\0';
- printf("Hello3\n");
- printf("Hello %s\n", string);
return string;
}
diff --git a/src/renderer/render.h b/src/renderer/render.h
index d1de515..e095e1c 100644
--- a/src/renderer/render.h
+++ b/src/renderer/render.h
@@ -1,7 +1,7 @@
#pragma once
-#include "render_types.h"
#include "loaders.h"
+#include "render_types.h"
// --- Lifecycle
/** @brief initialise the render system frontend */
diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h
index 45851fe..12b912d 100644
--- a/src/renderer/render_types.h
+++ b/src/renderer/render_types.h
@@ -107,7 +107,7 @@ KITC_DECL_TYPED_ARRAY(mesh) // creates "mesh_darray"
typedef struct model {
str8 name;
- mesh_darray meshes;
+ mesh_darray *meshes;
aabb_3d bbox;
material_darray *materials;
bool is_loaded;
diff --git a/src/resources/obj.c b/src/resources/obj.c
index d56e212..994e12a 100644
--- a/src/resources/obj.c
+++ b/src/resources/obj.c
@@ -11,8 +11,8 @@
#include <string.h>
#include "core.h"
-#include "file.h"
#include "darray.h"
+#include "file.h"
#include "log.h"
#include "maths.h"
#include "render.h"
@@ -39,7 +39,7 @@ bool model_load_obj_str(const char *file_string, model *out_model, bool invert_t
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);
+ /* printf("Loaded file %s\n", file_string); */
model model;
bool success = model_load_obj_str(file_string, &model, invert_textures_y);
@@ -195,15 +195,14 @@ bool model_load_obj_str(const char *file_string, model *out_model, bool invert_t
if (mesh_darray_len(meshes) > 256) {
printf("num meshes: %ld\n", mesh_darray_len(meshes));
}
- for (int i = 0; i < mesh_darray_len(meshes); i++) {
- mesh_darray_push(&out_model->meshes, ((mesh *)meshes->data)[i]);
- // TODO: bounding box calculation for each mesh
- }
+ out_model->meshes = meshes;
+ /* for (int i = 0; i < mesh_darray_len(meshes); i++) { */
+ /* mesh_darray_push(&out_model->meshes, ((mesh *)meshes->data)[i]); */
+ /* } */
+ // TODO: bounding box calculation for each mesh
// TODO: bounding box calculation for model
- for (int i = 0; i < material_darray_len(materials); i++) {
- material_darray_push(&out_model->materials, ((material *)materials->data)[i]);
- }
+ out_model->materials = materials;
return true;
}
diff --git a/src/std/str.h b/src/std/str.h
index 518d508..b87864e 100644
--- a/src/std/str.h
+++ b/src/std/str.h
@@ -75,6 +75,6 @@ static inline bool str8_is_null_term(str8 a) {
}
// TODO: move or delete this and replace with handling using our internal type
-static void skip_space(char *p) {
+static void skip_space(char* p) {
while (isspace((unsigned char)*p)) ++p;
}