polyadvent

A game engine from scratch in C
git clone git://jb55.com/polyadvent
Log | Files | Refs | README

commit a9b80ff7b235759f9155c3f2e14a7ef0e042730f
parent e2f5d340817a184e9ba04ed10bbfbdca349f87b2
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 20 Nov 2018 01:00:54 -0800

at least it doesn't crash. but now I'm a quad

Diffstat:
Msrc/render.c | 4++--
Msrc/update.c | 12+++++++-----
2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/src/render.c b/src/render.c @@ -7,7 +7,7 @@ #include "game.h" #include "mat4.h" #include "vec3.h" -#include "buffer.h" +#include "vbo.h" #include "shader.h" #include "geometry.h" #include "debug.h" @@ -346,7 +346,7 @@ void render (struct game *game, struct render_config *config) { recalc_normals(res->uniforms.normal_matrix, model_view, normal_matrix); check_gl(); - render_geometry(&entity->model.geom, &res->attributes, current_program); + render_geometry(get_geometry(&entity->model->geom_id), &res->attributes, current_program); check_gl(); } diff --git a/src/update.c b/src/update.c @@ -193,10 +193,11 @@ void resize_fbos(struct entity *player, struct fbo *shadow_buffer, // TODO: compute better bounds based const float factor = 1.5; - float left = player->model.geom.min[0] - factor; - float right = player->model.geom.max[0] + factor; - float bottom = player->model.geom.min[1] - factor; - float top = player->model.geom.max[1] + factor/2.0; + struct geometry *geom = get_geometry(&player->model->geom_id); + float left = geom->min[0] - factor; + float right = geom->max[0] + factor; + float bottom = geom->min[1] - factor; + float top = geom->max[1] + factor/2.0; const float near = -1.0; const float far = 5.0; @@ -279,10 +280,11 @@ void orbit_update_from_mouse(struct orbit *camera, struct input *input, float dt) { float target[3]; struct node *target_node = &player->node; + struct geometry *player_geom = get_geometry(&player->model->geom_id); node_recalc(target_node); vec3_copy(node_world(target_node), target); - vec3_add(target, V3(0.0, 0.0, player->model.geom.max[2] * 2.0), target); + vec3_add(target, V3(0.0, 0.0, player_geom->max[2] * 2.0), target); /* vec3_add(target, V3(0.0, 0.0, 10.0), target); */ float mx = 0.0, my = 0.0;