medfall

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

commit 3a5090c5ba3dce61eab09ee77367df4f3335591f
parent 7a9d2d10b39753fed7f1fd1b80cf66cf7be18a82
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Nov  5 17:25:45 +0200

Pass current time to game_frame

Diffstat:
game.h | 4++--
hm.cc | 2+-
main.cc | 4++--
terrain_manager.cc | 13++++++-------
terrain_manager.h | 2+-
5 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/game.h b/game.h @@ -88,10 +88,10 @@ struct GameInput { bool keys[ KEY_COUNT ]; }; -#define GAME_INIT( name ) void name( GameState * const game, GameMemory * const mem ) +#define GAME_INIT( name ) void name( GameState * game, GameMemory * mem ) typedef GAME_INIT( GameInit ); -#define GAME_FRAME( name ) void name( GameState * const game, GameMemory * const mem, const GameInput * const input, const float dt ) +#define GAME_FRAME( name ) void name( GameState * game, GameMemory * mem, const GameInput * input, double current_time, float dt ) typedef GAME_FRAME( GameFrame ); #endif // _GAME_H_ diff --git a/hm.cc b/hm.cc @@ -286,7 +286,7 @@ extern "C" GAME_FRAME( game_frame ) { ); const glm::mat4 VP = P * V; - terrain_render( &game->tm, V, VP, game->test_sun ); + terrain_render( &game->tm, V, VP, game->test_sun, current_time ); skybox_render( &game->skybox, game->angles ); glDisable( GL_DEPTH_TEST ); diff --git a/main.cc b/main.cc @@ -158,10 +158,10 @@ int main( int argc, char ** argv ) { input.keys[ KEY_EQUALS ] = glfwGetKey( window, GLFW_KEY_EQUAL ) == GLFW_PRESS; #if STATIC_GAME - game_frame( state, &mem, &input, dt ); + game_frame( state, &mem, &input, current_frame_time, dt ); #else if( game.frame ) { - game.frame( state, &mem, &input, dt ); + game.frame( state, &mem, &input, current_frame_time, dt ); } #endif diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -1,7 +1,6 @@ #include <stdio.h> #include <glm/glm.hpp> -#include <GLFW/glfw3.h> #include "intrinsics.h" #include "log.h" @@ -385,7 +384,7 @@ struct FSData { float sun; }; -void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun ) { +void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun, double current_time ) { u32 inited = 0; for( u16 vy = 0; vy < VIEW_SIZE; vy++ ) { for( u16 vx = 0; vx < VIEW_SIZE; vx++ ) { @@ -425,11 +424,11 @@ void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun ) /* start lighting */ float tbo1[ 15 ] = { - 500, 1500 + 500 * sin( glfwGetTime() + 3.14 * 1 / 5 ), 15, - 600, 1500 + 500 * sin( glfwGetTime() + 3.14 * 2 / 5 ), 15, - 700, 1500 + 500 * sin( glfwGetTime() + 3.14 * 3 / 5 ), 15, - 800, 1500 + 500 * sin( glfwGetTime() + 3.14 * 4 / 5 ), 15, - 900, 1500 + 500 * sin( glfwGetTime() + 3.14 * 5 / 5 ), 15, + 500, 1500 + 500 * sin( current_time + 3.14 * 1 / 5 ), 15, + 600, 1500 + 500 * sin( current_time + 3.14 * 2 / 5 ), 15, + 700, 1500 + 500 * sin( current_time + 3.14 * 3 / 5 ), 15, + 800, 1500 + 500 * sin( current_time + 3.14 * 4 / 5 ), 15, + 900, 1500 + 500 * sin( current_time + 3.14 * 5 / 5 ), 15, }; renderer_tb_data( tm->point_light_origins, tbo1, sizeof( tbo1 ) ); diff --git a/terrain_manager.h b/terrain_manager.h @@ -81,7 +81,7 @@ struct TerrainManager { void terrain_init( TerrainManager * tm, const char * tiles_dir, MemoryArena * arena, WorkQueue * background_tasks ); void terrain_teleport( TerrainManager * tm, glm::vec3 position ); void terrain_update( TerrainManager * tm, glm::vec3 position ); -void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun ); +void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun, double current_time ); float terrain_height( const TerrainManager * tm, glm::vec3 position ); #endif // _TERRAIN_MANAGER_H_