medfall

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

commit 7f2ed80c70284d4c43e22424b111118b5ad9deff
parent a4a11773d38b40ae4904c483e2f4d6f259c5623b
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Mon Oct 17 20:28:40 +0300

Add stupid STATIC_GAME hack

Diffstat:
build.bat | 6+++---
main.cc | 19+++++++++++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/build.bat b/build.bat @@ -30,8 +30,8 @@ cl terrain_manager.cc -c %FLAGS% cl work_queue.cc -c %FLAGS% REM -DGLAD_GLAPI_EXPORT -cl -LD %FLAGS% mod_btt.obj btt.obj gpubtt.obj glad.obj heightmap.obj skybox.obj stb_image.obj %COMMONOBJS% -Femod_btt.dll -link -EXPORT:game_init -EXPORT:game_frame -cl -LD %FLAGS% hm.obj terrain_manager.obj heightmap.obj btt.obj gpubtt.obj lz4.obj skybox.obj glad.obj %COMMONOBJS% glfw3dll.lib -Fehm.dll -link -EXPORT:game_init -EXPORT:game_frame +REM cl -LD %FLAGS% mod_btt.obj btt.obj gpubtt.obj glad.obj heightmap.obj skybox.obj stb_image.obj %COMMONOBJS% -Femod_btt.dll -link -EXPORT:game_init -EXPORT:game_frame +REM cl -LD %FLAGS% hm.obj terrain_manager.obj heightmap.obj btt.obj gpubtt.obj lz4.obj skybox.obj glad.obj %COMMONOBJS% glfw3dll.lib -Fehm.dll -link -EXPORT:game_init -EXPORT:game_frame -cl main.cc gl.obj glad.obj log.obj memory_arena.obj %EXEFLAGS% -Femedfall.exe +cl main.cc gl.obj glad.obj log.obj memory_arena.obj hm.obj terrain_manager.obj heightmap.obj btt.obj gpubtt.obj lz4.obj skybox.obj glad.obj -DSTATIC_GAME %COMMONOBJS% %EXEFLAGS% -Femedfall.exe cl pp.cc stb_image.obj lz4.obj lz4hc.obj memory_arena.obj strlcpy.obj %EXEFLAGS% diff --git a/main.cc b/main.cc @@ -73,6 +73,11 @@ static bool should_reload_game( const char * const path, const time_t lib_write_ return file_last_write_time( path ) > lib_write_time; } +#if STATIC_GAME +extern "C" GameInit game_init; +extern "C" GameFrame game_frame; +#endif + #if PLATFORM_LINUX #include "autogdb.h" #endif @@ -82,11 +87,13 @@ int main( int argc, char ** argv ) { install_debug_signal_handlers( true ); #endif +#if !STATIC_GAME #if PLATFORM_LINUX const char * game_library_path = argc == 2 ? argv[ 1 ] : "./hm.so"; #elif PLATFORM_WINDOWS const char * game_library_path = argc == 2 ? argv[ 1 ] : "./hm.dll"; #endif +#endif size_t persistent_size = megabytes( 64 ); u8 * persistent_memory = ( u8 * ) malloc( persistent_size ); @@ -102,8 +109,12 @@ int main( int argc, char ** argv ) { GLFWwindow * window = gl_init(); +#if STATIC_GAME + game_init( state, &mem ); +#else Game game = load_game( game_library_path ); game.init( state, &mem ); +#endif const float program_start_time = glfwGetTime(); float last_frame_time = program_start_time; @@ -120,12 +131,14 @@ int main( int argc, char ** argv ) { break; } +#if !STATIC_GAME if( ( s32 ) current_frame_time != ( s32 ) last_frame_time ) { if( should_reload_game( game_library_path, game.lib_write_time ) ) { unload_game( &game ); game = load_game( game_library_path ); } } +#endif // TODO: do this properly GameInput input = { }; @@ -145,9 +158,13 @@ int main( int argc, char ** argv ) { input.keys[ KEY_MINUS ] = glfwGetKey( window, GLFW_KEY_MINUS ) == GLFW_PRESS; input.keys[ KEY_EQUALS ] = glfwGetKey( window, GLFW_KEY_EQUAL ) == GLFW_PRESS; +#if STATIC_GAME + game_frame( state, &mem, &input, dt ); +#else if( game.frame ) { game.frame( state, &mem, &input, dt ); } +#endif glfwSwapBuffers( window ); glfwPollEvents(); @@ -163,7 +180,9 @@ int main( int argc, char ** argv ) { const float program_run_time = glfwGetTime() - program_start_time; +#if !STATIC_GAME unload_game( &game ); +#endif gl_term();