polyadvent

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

commit 871f56ef81427b53c60097e49faaa210fb7f4054
parent 25e394ca852138b379b95f447aef43b42a8697f0
Author: William Casarin <jb55@jb55.com>
Date:   Thu,  8 Nov 2018 19:39:19 -0800

fix shadows, move camera a bit

Diffstat:
Msrc/render.c | 17+++++++++++------
Msrc/update.c | 5+++--
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/render.c b/src/render.c @@ -273,6 +273,17 @@ void render (struct game *game, struct render_config *config) { struct gpu_program *default_program = &game->test_resources.programs[DEFAULT_PROGRAM]; + /* mat4_multiply(view_proj, res->skybox.node.mat, mvp); */ + if (!config->is_depth_pass) { + mat4_inverse(camera, view); + mat4_remove_translations(view); + mat4_multiply(projection, view, view_proj); + render_skybox(&res->skybox, view_proj); + } + + mat4_inverse(camera, view); + mat4_multiply(projection, view, view_proj); + if (config->is_depth_pass) { glDisable(GL_CULL_FACE); mat4_multiply(bias_matrix, view_proj, config->depth_vp); @@ -282,12 +293,6 @@ void render (struct game *game, struct render_config *config) { } mat4_inverse(camera, view); - mat4_remove_translations(view); - mat4_multiply(projection, view, view_proj); - /* mat4_multiply(view_proj, res->skybox.node.mat, mvp); */ - render_skybox(&res->skybox, view_proj); - - mat4_inverse(camera, view); mat4_multiply(projection, view, view_proj); for (u32 i = 0; i < num_entities; ++i) { diff --git a/src/update.c b/src/update.c @@ -304,11 +304,12 @@ static void gravity(struct game *game) { void orbit_update_from_mouse(struct orbit *camera, struct input *input, float mouse_sens, struct entity *player, float dt) { - float *target; + float target[3]; struct node *target_node = &player->node; node_recalc(target_node); - target = node_world(target_node); + vec3_copy(node_world(target_node), target); + vec3_add(target, V3(0.0, 0.0, 100.0), target); float mx = 0.0, my = 0.0; if (input_is_dragging(input, SDL_BUTTON_LEFT) ||