diff --git a/HandmadeHero.vcxproj b/HandmadeHero.vcxproj index da364a8..3443584 100644 --- a/HandmadeHero.vcxproj +++ b/HandmadeHero.vcxproj @@ -15,40 +15,55 @@ - $(ProjectDir)project;$(ProjectDir)project\engine;$(ProjectDir)project\platform;$(IncludePath) + $(ProjectDir)project;$(ProjectDir)project\engine;$(ProjectDir)project\platform;$(IncludePath);$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include $(ProjectDir)data;$(windir)System32;$(LibraryPath) pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)scripts\build.ps1 msvc dev engine - pwsh ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)scripts\clean.ps1 + pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)scripts\clean.ps1 GEN_TIME;INTELLISENSE_DIRECTIVES;Build_Development;Build_Debug;$(NMakePreprocessorDefinitions) - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.37.32822\include + $(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\ucrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\um;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared;C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\cppwinrt;C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.38.33130\include + true + true - + - + + + + + + + + + + + + + + @@ -84,7 +99,6 @@ - @@ -93,7 +107,8 @@ - + + diff --git a/project/codegen/engine_gen.cpp b/project/codegen/engine_gen.cpp index 94b94bb..7bf3f60 100644 --- a/project/codegen/engine_gen.cpp +++ b/project/codegen/engine_gen.cpp @@ -1,6 +1,5 @@ #include "platform/compiler_ignores.hpp" -#if GEN_TIME #define GEN_DEFINE_LIBRARY_CODE_CONSTANTS #define GEN_IMPLEMENTATION #define GEN_BENCHMARK @@ -25,6 +24,7 @@ using namespace gen; constexpr StrC fname_vec_header = txt("vectors.hpp"); #pragma push_macro("scast") +#pragma push_macro("Zero") #undef scast constexpr char const* vec2f_ops = stringize( template<> @@ -254,6 +254,7 @@ constexpr char const* vec2i_ops = stringize( } ); #pragma pop_macro("scast") +#pragma pop_macro("Zero") #define gen_vec2f( vec_name, type ) gen__vec2f( txt( stringize(vec_name) ), txt( stringize(type) ) ) CodeBody gen__vec2f( StrC vec_name, StrC type ) @@ -296,7 +297,7 @@ CodeBody gen__vec2i( StrC vec_name, StrC type ) }; }; ))); - + CodeBody vec_ops = parse_global_body( token_fmt( "type", vec_name, "unit_type", type, vec2i_ops) ); CodeBody vec_def = def_global_body( args( vec_struct, @@ -481,6 +482,8 @@ Code gen__phys2( StrC type ) return result; } ))); +#pragma pop_macro("rcast") +#pragma pop_macro("pcast") CodeBody result = def_global_body( args( pos_struct, @@ -494,8 +497,6 @@ Code gen__phys2( StrC type ) ops )); return result; -#pragma pop_macro("rcast") -#pragma pop_macro("pcast") } int gen_main() @@ -558,4 +559,3 @@ int gen_main() // gen::deinit(); return 0; } -#endif diff --git a/project/engine/engine.cpp b/project/engine/engine.cpp index 87ef506..5c9d42b 100644 --- a/project/engine/engine.cpp +++ b/project/engine/engine.cpp @@ -17,8 +17,10 @@ struct EngineState MemoryArena world_arena; +#if Build_Development f32 auto_snapshot_interval; f32 auto_snapshot_timer; +#endif s32 wave_tone_hz; s32 tone_volume; @@ -93,7 +95,9 @@ void input_poll_engine_actions( InputState* input, EngineActions* actions ) actions->move_up = (mouse->vertical_wheel.end > 0.f) * 10; actions->move_down = (mouse->vertical_wheel.end < 0.f) * 10; +#if Build_Development actions->load_auto_snapshot |= pressed( keyboard->L ) && keyboard->right_alt.ended_down; +#endif } internal @@ -390,7 +394,9 @@ void startup( OffscreenBuffer* back_buffer, Memory* memory, platform::ModuleAPI* Engine_Context = & state->context; +#if Build_Development state->auto_snapshot_interval = 60.f; +#endif state->tone_volume = 1000; @@ -712,6 +718,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back state->context.delta_time = delta_time; // Engine auto_snapshot + #if Build_Development { state->auto_snapshot_timer += delta_time; if ( state->auto_snapshot_timer >= state->auto_snapshot_interval ) @@ -726,6 +733,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back state->auto_snapshot_timer = 0.f; } } + #endif ControllerState* controller = & input->controllers[0]; @@ -734,6 +742,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back input_poll_engine_actions( input, & engine_actions ); +#if Build_Development if ( engine_actions.load_auto_snapshot ) { s32 current_slot = memory->active_snapshot_slot; @@ -742,7 +751,6 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back memory->active_snapshot_slot = current_slot; } -#if Build_Development // Ease of use: Allow user to press L key without shift if engine loop recording is active. engine_actions.loop_mode_engine |= engine_actions.loop_mode_game && memory->engine_loop_active; @@ -800,13 +808,13 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back state->sample_wave_switch ^= true; } + #if Build_Development if ( engine_actions.loop_mode_game && ! memory->engine_loop_active ) { process_loop_mode( & take_game_snapshot, & load_game_snapshot, memory, state, input, platform_api ); memory->game_loop_active = memory->replay_mode > ReplayMode_Off; } - #if Build_Development if ( engine_actions.pause_renderer ) { if ( state->renderer_paused ) @@ -1181,6 +1189,7 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back , & hero_bitmaps->head ); #endif +#if Build_Development // Auto-Snapshot percent bar if (1) { @@ -1191,7 +1200,6 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back , 0.f, 0.15f, 0.35f ); } -#if Build_Development if ( memory->replay_mode == ReplayMode_Record ) { // TODO(Ed) : We're prob going to need a better indicator for recording... diff --git a/project/engine/engine.hpp b/project/engine/engine.hpp index 44d34ab..63fac85 100644 --- a/project/engine/engine.hpp +++ b/project/engine/engine.hpp @@ -6,7 +6,6 @@ #if INTELLISENSE_DIRECTIVES #include "platform/platform.hpp" -#include "gen/vectors.hpp" #include "engine_module.hpp" #include "tile_map.hpp" diff --git a/project/engine/engine_to_platform_api.hpp b/project/engine/engine_to_platform_api.hpp index b7f665a..40fbecc 100644 --- a/project/engine/engine_to_platform_api.hpp +++ b/project/engine/engine_to_platform_api.hpp @@ -4,6 +4,7 @@ #pragma once #if INTELLISENSE_DIRECTIVES #include "engine_module.hpp" +#include "input.hpp" #endif NS_ENGINE_BEGIN diff --git a/project/platform/macros.hpp b/project/platform/macros.hpp index 6587951..3a06a68 100644 --- a/project/platform/macros.hpp +++ b/project/platform/macros.hpp @@ -64,6 +64,6 @@ # define fatal( message ) platform::impl_fatal( message ) #else # define congrats( message ) -# define ensure( condition, message ) +# define ensure( condition, message ) true # define fatal( message ) #endif diff --git a/project/platform/types.hpp b/project/platform/types.hpp index 5d2c136..a64ea39 100644 --- a/project/platform/types.hpp +++ b/project/platform/types.hpp @@ -1,3 +1,7 @@ +#if INTELLISENSE_DIRECTIVES +#include "grime.hpp" +#endif + #pragma once #pragma region Basic Types diff --git a/project/platform/win32/win32_audio.cpp b/project/platform/win32/win32_audio.cpp index cddf21e..b11504c 100644 --- a/project/platform/win32/win32_audio.cpp +++ b/project/platform/win32/win32_audio.cpp @@ -1,7 +1,24 @@ #if INTELLISENSE_DIRECTIVES #include "platform.hpp" #include "engine/engine.hpp" +#include "engine/engine_to_platform_api.hpp" #include "win32.hpp" + +// This is the "backbuffer" data related to the windowing surface provided by the operating system. +struct OffscreenBuffer +{ + BITMAPINFO info; + char _PAD_[4]; + void* memory; // Lets use directly mess with the "pixel's memory buffer" + s32 width; + s32 height; + s32 pitch; + s32 bytes_per_pixel; +}; + +extern OffscreenBuffer Surface_Back_Buffer; +extern f32 Engine_Frame_Target_MS; +extern u32 Engine_Refresh_Hz; #endif NS_PLATFORM_BEGIN diff --git a/project/platform/win32/win32_platform.cpp b/project/platform/win32/win32_platform.cpp index dadf2bc..252dbec 100644 --- a/project/platform/win32/win32_platform.cpp +++ b/project/platform/win32/win32_platform.cpp @@ -1081,6 +1081,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho engine_api.shutdown( & engine_memory, & platform_api ); +#if Build_Development for ( s32 slot = 0; slot < engine_memory.Num_Snapshot_Slots; ++slot ) { engine::MemorySnapshot& snapshot = engine_memory.snapshots[ slot ]; @@ -1089,6 +1090,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho CloseHandle( snapshot.opaque_handle_2 ); CloseHandle( snapshot.opaque_handle ); } +#endif unload_engine_module_api( & engine_api ); DeleteFileA( Path_Engine_DLL_InUse );