commit e4391f93d5b9780ca1cb364b59f8737cbeb3bec7 parent 5983f7477cdfed434030ea637587c620b594f5b1 Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Sep 10 21:54:25 -0700 Dynamic sun in terrain renderer Diffstat:
hm.cc | | | 8 | +++++++- |
diff --git a/hm.cc b/hm.cc @@ -131,6 +131,8 @@ extern "C" GAME_INIT( game_init ) { game->test_at_position = glGetAttribLocation( game->test_shader, "position" ); game->test_at_colour = glGetAttribLocation( game->test_shader, "colour" ); + game->test_sun = 0.3f; + const size_t triangles = 65536; ImmediateTriangle * immediate_memory = memarena_push_many( &mem->persistent_arena, ImmediateTriangle, triangles ); immediate_init( &game->test_immediate, immediate_memory, triangles ); @@ -256,6 +258,10 @@ extern "C" GAME_FRAME( game_frame ) { game->angles.x += pitch * dt * 2; game->angles.y += yaw * dt * 2; + const float dsun = ( input->keys[ KEY_EQUALS ] - input->keys[ KEY_MINUS ] ) * dt; + game->test_sun += dsun; + if( dsun != 0 ) printf( "sun: %.4f\n", game->test_sun ); + // const float speed = 6.0f; const float speed = 100.0f; game->pos += angles_to_vector_xy( game->angles ) * speed * dt * ( float ) fb; @@ -280,7 +286,7 @@ extern "C" GAME_FRAME( game_frame ) { ); const glm::mat4 VP = P * V; - terrain_render( &game->tm, V, VP, 0.3f ); + terrain_render( &game->tm, V, VP, game->test_sun ); skybox_render( &game->skybox, game->angles ); glDisable( GL_DEPTH_TEST );