commit 0a037b5a71c19e9371aa805c3658074254af0172
parent fbeeb6961b924a2f705656ccea36f5eb737004fd
Author: William Casarin <jb55@jb55.com>
Date: Sat, 29 Jun 2019 00:51:51 -0700
stuff is crashing, bleh
Diffstat:
7 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/data/models/pirate-officer.ply b/data/models/pirate_officer.ply
diff --git a/src/game.c b/src/game.c
@@ -178,7 +178,7 @@ void game_init(struct game *game, int width, int height) {
// player entity
player = new_entity(&res->player_id);
assert(res->player_id.index == 1);
- player->model = get_model(MODEL_PIRATEOFFICER);
+ player->model = get_model(model_pirate_officer);
player->node.label = "player";
node_attach(&player->node, root);
node_translate(&player->node, V3(terrain->size/2.,terrain->size/2.,0.0));
diff --git a/src/geometry.c b/src/geometry.c
@@ -2,6 +2,7 @@
#include "geometry.h"
#include "util.h"
#include "resource.h"
+#include "debug.h"
#include <assert.h>
@@ -57,6 +58,7 @@ void render_geometry(struct geometry *geom, gpu_addr *vertex_attrs,
//check_for_patches(program, &type);
bind_geometry(geom, vertex_attrs);
if (geom->num_indices) {
+ debug("geom->num_indices %d\n", geom->num_indices);
glDrawElements(type,
geom->num_indices, /* count */
GL_UNSIGNED_INT, /* type */
diff --git a/src/model.c b/src/model.c
@@ -4,12 +4,12 @@
#include "resource.h"
#include <assert.h>
-#define MODELDEF(name) { .id = MODEL_##name, .loaded = 0, .file = #name }
+#define MODELDEF(name) { .id = model_##name, .loaded = 0, .file = #name }
static struct model_def static_models[NUM_STATIC_MODELS] = {
- MODELDEF(TOWER),
- MODELDEF(ICOSPHERE),
- MODELDEF(PIRATEOFFICER),
+ MODELDEF(tower),
+ MODELDEF(icosphere),
+ MODELDEF(pirate_officer),
};
static struct resource_manager dyn_modelman;
diff --git a/src/model.h b/src/model.h
@@ -15,9 +15,9 @@
typedef struct resource_id model_id;
enum static_model {
- MODEL_TOWER,
- MODEL_ICOSPHERE,
- MODEL_PIRATEOFFICER,
+ model_tower,
+ model_icosphere,
+ model_pirate_officer,
NUM_STATIC_MODELS
};
diff --git a/src/resource.c b/src/resource.c
@@ -40,8 +40,8 @@ void init_resource_manager(struct resource_manager *r, u32 elem_size,
assert(initial_elements != 0);
- r->resources = calloc(initial_elements+1, elem_size);
- r->ids = calloc(initial_elements+1, sizeof(*r->ids));
+ r->resources = calloc(initial_elements, elem_size);
+ r->ids = calloc(initial_elements, sizeof(*r->ids));
}
void destroy_resource_manager(struct resource_manager *r) {
diff --git a/src/scene.c b/src/scene.c
@@ -26,7 +26,7 @@ void default_scene(struct game *game) {
player->flags &= ~ENT_INVISIBLE;
struct entity *tower = new_entity(NULL);
- tower->model = get_model(MODEL_TOWER);
+ tower->model = get_model(model_tower);
tower->node.label = "tower";
node_attach(&tower->node, &player->node);
node_translate(&tower->node, V3(0.0, 50.0, 0.0));
@@ -40,5 +40,5 @@ void default_scene(struct game *game) {
}
void pbr_scene(struct game *game) {
- struct model *sphere = get_model(MODEL_ICOSPHERE);
+ struct model *sphere = get_model(model_icosphere);
}