medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 67211c8da8c72cb1a68a45dd964538cb50da59f5
parent 1a32c72cca5be663e968fbd123f2448f93befe64
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Nov  7 22:18:37 +0200

Use m4 instead of glm::mat4 in shadow_map.cc

Diffstat:
shadow_map.cc | 25+++++++------------------
1 file changed, 7 insertions(+), 18 deletions(-)
diff --git a/shadow_map.cc b/shadow_map.cc @@ -6,6 +6,7 @@ #include "game.h" #include "intrinsics.h" +#include "linear_algebra.h" #include "log.h" static ImmediateTriangle triangles[ 512000 ]; @@ -125,21 +126,10 @@ static void update_camera( *out_angles = angles + glm::vec3( dt * pitch * angular_speed, dt * yaw * angular_speed, 0 ); } -static void camera_to_vp( glm::vec3 position, glm::vec3 angles, glm::mat4 * out_vp ) { - const glm::mat4 P( glm::perspective( glm::radians( 120.0f ), ( float ) WIDTH / ( float ) HEIGHT, NEAR_PLANE_DEPTH, 25.0f ) ); - - *out_vp = glm::translate( - glm::rotate( - glm::rotate( - P, - angles.x, - glm::vec3( 1, 0, 0 ) - ), - angles.y, - glm::vec3( 0, 0, 1 ) - ), - -position - ); +static void camera_to_vp( glm::vec3 position, glm::vec3 angles, m4 * vp ) { + const m4 P = m4_perspective( 120.0f, ( float ) WIDTH / ( float ) HEIGHT, NEAR_PLANE_DEPTH, 25.0f ); + + *vp = m4_translation( -GLMV3( position ) ) * m4_rotz( -angles.y ) * m4_rotx( -angles.x ) * P; } const u32 SHADOW_WIDTH = 1024; @@ -189,13 +179,12 @@ extern "C" GAME_INIT( game_init ) { } extern "C" GAME_FRAME( game_frame ) { - update_camera( input, dt, game->pos, game->angles, &game->pos, &game->angles ); - glm::mat4 vp; + m4 vp; camera_to_vp( game->pos, game->angles, &vp ); glUseProgram( prog ); - glUniformMatrix4fv( un_vp, 1, GL_FALSE, glm::value_ptr( vp ) ); + glUniformMatrix4fv( un_vp, 1, GL_FALSE, ( float * ) &vp ); glViewport( 0, 0, SHADOW_WIDTH, SHADOW_HEIGHT ); glBindFramebuffer( GL_DRAW_FRAMEBUFFER, fbo );