diff --git a/.vscode/bookmarks.json b/.vscode/bookmarks.json index 0a4c7e0..ebe0a41 100644 --- a/.vscode/bookmarks.json +++ b/.vscode/bookmarks.json @@ -4,17 +4,17 @@ "path": "project/platform/win32/win32_platform.cpp", "bookmarks": [ { - "line": 39, + "line": 32, "column": 0, "label": "Struct Defs" }, { - "line": 58, + "line": 51, "column": 0, "label": "Static Data" }, { - "line": 1009, + "line": 1002, "column": 0, "label": "Main Loop : End" } diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index c3b93be..ec49ff9 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -6,6 +6,7 @@ "${workspaceFolder}/project/", "${workspaceFolder}/project/dependencies/", "${workspaceFolder}/project/platform/", + "${workspaceFolder}/project/engine/", ], "defines": [ "_DEBUG", @@ -26,6 +27,7 @@ "${workspaceFolder}/project/", "${workspaceFolder}/project/dependencies/", "${workspaceFolder}/project/platform/", + "${workspaceFolder}/project/engine/", ], "defines": [ "_DEBUG", diff --git a/HandmadeHero.10x b/HandmadeHero.10x index 6867f9e..767c7e4 100644 --- a/HandmadeHero.10x +++ b/HandmadeHero.10x @@ -8,8 +8,8 @@ true false false - pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev debug engine - pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev debug platform + pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev engine + pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev platform pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/clean.ps1 @@ -44,6 +44,7 @@ GEN_TIME Build_Debug Build_Development + INTELLISENSE_DIRECTIVES=1 @@ -61,10 +62,11 @@ - - Debug + + Dev:x64 - + + Dev diff --git a/HandmadeHero.vcxproj b/HandmadeHero.vcxproj index 716b78a..da364a8 100644 --- a/HandmadeHero.vcxproj +++ b/HandmadeHero.vcxproj @@ -15,12 +15,12 @@ - $(ProjectDir)project;$(IncludePath); + $(ProjectDir)project;$(ProjectDir)project\engine;$(ProjectDir)project\platform;$(IncludePath) $(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 - GEN_TIME;Build_Development;Build_Debug;$(NMakePreprocessorDefinitions) - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath); + 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 @@ -42,7 +42,6 @@ - @@ -57,7 +56,6 @@ - @@ -75,10 +73,22 @@ + + + + + + + + + + + + @@ -86,6 +96,10 @@ + + + + Makefile true diff --git a/docs/Day 031.md b/docs/Day 031.md new file mode 100644 index 0000000..e1d1e6c --- /dev/null +++ b/docs/Day 031.md @@ -0,0 +1,26 @@ +# Day 31 + +This was really a prepatory day for day 32 so I did some extra stuff... +I setup codebase so now that the build translation unit files have every single file included for that unit explicitly. +I do not (or should not) have nested includes other than from `grime.hpp` + +## Side Tracking + +I did some refactoring and added `INTELLISENSE_DIRECTIVES` preprocessor conditional blocks throughout the codebase. + +I wanted to see if I could get all IDE/Editors I've ever used to support the project without bad errors from parsing failures. +Unfortunately getting Visual Studio and Rider's intellisense to behave was not possible. +This is mostly from how the code is structured across files currently. +I'll have to re-sturcture it down the line to make it more IDE friendly. + +10xEditor Needs help with the intellisense directives macros, but otherwise was able to parse everything quite accurately. + +VSCode has some failures in few files, they are nearly the same failures as VS2022, however like 10xEditor I saw that it has include awareness beyond a single file's scope! +In fact, if I open all the files, the parser corrects itself (you can close them afterwards). It essentially cached the include graph for the project by doing so for the lifetime of the process. + +VS2022 has issues due to it strictly parsing each file, without awareness of whats going on in other files. +(It doesn't build a proper include graph). + +Rider just straight up broken, it seems to not work every well with NMake projects. +At least, you can't depend on it to use the external include directories field properly. +It will show errors for all external include symbols. diff --git a/project/Readme.md b/project/Readme.md new file mode 100644 index 0000000..131bfe6 --- /dev/null +++ b/project/Readme.md @@ -0,0 +1,25 @@ +# Project Documentation + +Currently the project is split into two modules: + +* Platform +* Engine + +This project takes the approach of doing all includes for a module in a single translation unit. +Any includes within the project files outside of the translation unit files used for builds are for intellisense purposes. +They are wrapped in `INTELLISENSE_DIRECTIVES` preprocessor conditional, and are necessary for most editors as they do not parse the project directories properly. +(They do a rudimentary parse on a per-file basis on includes ussually) + +## Platform + +Translation Unit: `handmade_win32.cpp` for Windows + +Deals with providing the core library for the project along with dealing with th platform specific grime. +Only supports Windows at the momment. May add suport for macos or Ubuntu/SteamOS(linux) in the future. + +## Engine + +Translation Unit: `handmade_engine.cpp` + +Currently deals with both *engine* and *game* code until I see a point where I can segment the two into separate modules. +The the "proto-code" for the game module is within `handmade.hpp` & `handmade.cpp` diff --git a/project/codegen/engine_postbuild_gen.cpp b/project/codegen/engine_postbuild_gen.cpp index 3b66ebf..6834652 100644 --- a/project/codegen/engine_postbuild_gen.cpp +++ b/project/codegen/engine_postbuild_gen.cpp @@ -15,7 +15,13 @@ #undef do_once_end using namespace gen; +#include "platform/grime.hpp" +#include "platform/macros.hpp" +#include "platform/types.hpp" +#include "platform/strings.hpp" +#include "platform/platform.hpp" +#include "engine/engine.hpp" #include "engine/engine_to_platform_api.hpp" constexpr StrC fname_handmade_engine_symbols = txt("handmade_engine.symbols"); diff --git a/project/engine/engine.cpp b/project/engine/engine.cpp index bd606a6..e7495fc 100644 --- a/project/engine/engine.cpp +++ b/project/engine/engine.cpp @@ -1,14 +1,15 @@ -//#include "win32.h" +#if INTELLISENSE_DIRECTIVES #include "engine.hpp" #include "engine_to_platform_api.hpp" #include "handmade.hpp" +#endif NS_ENGINE_BEGIN #define pressed( btn ) (btn.ended_down && btn.half_transitions > 0) // Used to determine if analog input is at move threshold -constexpr f32 analog__move_threshold = 0.5f; +constexpr f32 analog_move_threshold = 0.5f; struct EngineActions { @@ -58,41 +59,9 @@ struct EngineState hh::Memory game_memory; }; +NS_ENGINE_END #include "test_samples.cpp" - -internal void -render_player( OffscreenBuffer* buffer, s32 pos_x, s32 pos_y ) -{ - u8* end_of_buffer = rcast(u8*, buffer->memory) - - buffer->bytes_per_pixel * buffer->width - + buffer->pitch * buffer->height; - - s32 top = pos_y; - s32 bottom = pos_y + 10; - - u32 color = 0xFFFFFFFF; - - for ( s32 coord_x = pos_x; coord_x < (pos_x+ 10); ++ coord_x ) - { - u8* - pixel_byte = rcast(u8*, buffer->memory); - pixel_byte += coord_x * buffer->bytes_per_pixel; - pixel_byte += top * buffer->pitch; - - for ( s32 coord_y = top; coord_y < bottom; ++ coord_y ) - { - if ( pixel_byte < buffer->memory || pixel_byte >= end_of_buffer ) - continue; - - s32* pixel = rcast(s32*, pixel_byte); - *pixel = color; - - - - pixel_byte += buffer->pitch; - } - } -} +NS_ENGINE_BEGIN #if Build_Development using SnapshotFn = void ( Memory* memory, platform::ModuleAPI* platform_api ); @@ -382,26 +351,6 @@ output_sound( EngineState* state, AudioBuffer* sound_buffer, GetSoundSampleValue } } -inline -s32 floor_f32_to_s32( f32 value ) -{ - // TODO : Casey wants to use an intrinsic - return scast(s32, floorf( value )); -} - -inline -s32 round_f32_to_s32( f32 value ) -{ - // TODO(Ed) : Casey wants to use an intrinsic - return scast(s32, value + 0.5f); -} - -inline -s32 truncate_f32_to_s32( f32 value ) -{ - return scast(s32, value); -} - internal void draw_rectangle( OffscreenBuffer* buffer , f32 min_x, f32 min_y @@ -522,17 +471,19 @@ CanonPosition get_cannonical_position( World* world, RawPosition raw_pos ) f32 pos_x = ( raw_pos.x - world->tile_upper_left_x ); f32 pos_y = ( raw_pos.y - world->tile_upper_left_y ); + + f32 tile_size = scast(f32, world->tile_size_in_pixels); - s32 tile_x = floor_f32_to_s32( pos_x / world->tile_width ); - s32 tile_y = floor_f32_to_s32( pos_y / world->tile_height ); + s32 tile_x = floor_f32_to_s32( pos_x / tile_size ); + s32 tile_y = floor_f32_to_s32( pos_y / tile_size ); - f32 tile_rel_x = pos_x - scast(f32, tile_x) * world->tile_width; - f32 tile_rel_y = pos_y - scast(f32, tile_y) * world->tile_height; + f32 tile_rel_x = pos_x - scast(f32, tile_x) * tile_size; + f32 tile_rel_y = pos_y - scast(f32, tile_y) * tile_size; assert( tile_rel_x >= 0.f ); assert( tile_rel_y >= 0.f ); - assert( tile_rel_x < world->tile_width ); - assert( tile_rel_y < world->tile_height ); + assert( tile_rel_x < tile_size ); + assert( tile_rel_y < tile_size ); /* The puprpose of this is to be able to detect if the point is outside of the tilemap, @@ -820,16 +771,18 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back tile_maps[1][1].tiles = rcast(u32*, tiles_11); World world; + world.tile_size_in_meters = 1.4f; + world.tile_size_in_pixels = 85; + + f32 tile_size_in_pixels = scast(f32, world.tile_size_in_pixels); + world.num_tiles_x = tile_map_num_x; world.num_tiles_y = tile_map_num_y; f32 scale = 85; - world.tile_width = scale; - world.tile_height = scale * 1.05f; - - world.tile_upper_left_x = -(world.tile_width * 0.5f); - world.tile_upper_left_y = -(world.tile_height * 0.5f); + world.tile_upper_left_x = -( tile_size_in_pixels * 0.5f); + world.tile_upper_left_y = -( tile_size_in_pixels * 0.25f); world.tilemaps_num_x = 2; world.tilemaps_num_y = 2; @@ -839,8 +792,8 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back TileMap* current_tile_map = world_get_tilemap( & world, game_state->tile_map_x, game_state->tile_map_y ); assert( current_tile_map != nullptr ); - player->width = world.tile_width * 0.75f; - player->height = world.tile_height; + player->width = tile_size_in_pixels * 0.70f; + player->height = tile_size_in_pixels * 0.9f; f32 player_half_width = player->width / 2.f; f32 player_quarter_height = player->height / 4.f; @@ -865,18 +818,21 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back b32 valid_new_pos = true; { - RawPosition test_pos = { new_player_pos_x - player_half_width, new_player_pos_y - player_quarter_height, game_state->tile_map_x, game_state->tile_map_y }; + RawPosition test_pos = { + new_player_pos_x - player_half_width, new_player_pos_y - player_quarter_height, + game_state->tile_map_x, game_state->tile_map_y + }; valid_new_pos &= world_is_point_empty( & world, test_pos ); - test_pos.x = new_player_pos_x + player_half_width; + test_pos.x = new_player_pos_x + player_half_width; valid_new_pos &= world_is_point_empty( & world, test_pos ); - test_pos.x = new_player_pos_x - player_half_width; - test_pos.y = new_player_pos_y; + test_pos.x = new_player_pos_x - player_half_width; + test_pos.y = new_player_pos_y; valid_new_pos &= world_is_point_empty( & world, test_pos ); - test_pos.x = new_player_pos_x + player_half_width; + test_pos.x = new_player_pos_x + player_half_width; valid_new_pos &= world_is_point_empty( & world, test_pos ); } @@ -890,8 +846,8 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back // current_tile_map = world_get_tilemap( & world, game_state->tile_map_x, game_state->tile_map_y ); - player->pos_x = world.tile_upper_left_x + world.tile_width * scast(f32, canon_pos.tile_x) + canon_pos.x; - player->pos_y = world.tile_upper_left_y + world.tile_height * scast(f32, canon_pos.tile_y) + canon_pos.y; + player->pos_x = world.tile_upper_left_x + tile_size_in_pixels * scast(f32, canon_pos.tile_x) + canon_pos.x; + player->pos_y = world.tile_upper_left_y + tile_size_in_pixels * scast(f32, canon_pos.tile_y) + canon_pos.y; } // player_tile_x @@ -934,10 +890,10 @@ void update_and_render( f32 delta_time, InputState* input, OffscreenBuffer* back grey[2] = 0.22f; } - f32 min_x = world.tile_upper_left_x + scast(f32, col) * world.tile_width; - f32 min_y = world.tile_upper_left_y + scast(f32, row) * world.tile_height; - f32 max_x = min_x + world.tile_width; - f32 max_y = min_y + world.tile_height; + f32 min_x = world.tile_upper_left_x + scast(f32, col) * tile_size_in_pixels; + f32 min_y = world.tile_upper_left_y + scast(f32, row) * tile_size_in_pixels; + f32 max_x = min_x + tile_size_in_pixels; + f32 max_y = min_y + tile_size_in_pixels; draw_rectangle( back_buffer , min_x, min_y diff --git a/project/engine/engine.hpp b/project/engine/engine.hpp index 637e41a..95a3744 100644 --- a/project/engine/engine.hpp +++ b/project/engine/engine.hpp @@ -4,7 +4,9 @@ #pragma once +#if INTELLISENSE_DIRECTIVES #include "platform/platform.hpp" +#endif #define NS_ENGINE_BEGIN namespace engine { #define NS_ENGINE_END } @@ -282,12 +284,12 @@ struct TileMap struct World { + f32 tile_size_in_meters; + s32 tile_size_in_pixels; + f32 tile_upper_left_x; f32 tile_upper_left_y; - f32 tile_width; - f32 tile_height; - s32 num_tiles_x; // Number of tiles on the x-axis for a tilemap. s32 num_tiles_y; // Number of tiles on the y-axis for a tilemap. @@ -300,11 +302,16 @@ struct World struct CanonPosition { + // TODO(Ed): Convert these to resolution-indenpent rep of world units (a proper vector space?)) // Note: Tile-Relative position - // TODO(Ed) : These are still in pixels f32 x; f32 y; + /* TODO(Ed) : + Take the tile map x & y and the tile x & y + where there is some low bits for the tile index + and the high bits are the tile "page". + */ s32 tile_map_x; s32 tile_map_y; diff --git a/project/engine/engine_to_platform_api.hpp b/project/engine/engine_to_platform_api.hpp index d7676c2..f810d8a 100644 --- a/project/engine/engine_to_platform_api.hpp +++ b/project/engine/engine_to_platform_api.hpp @@ -2,7 +2,6 @@ This represents the API only accessible to the platform layer to fullfill for the engine layer. */ #pragma once -#include "engine/engine.hpp" #ifndef Engine_API # define Engine_API @@ -16,12 +15,16 @@ using ShutdownFn = void( Memory* memory, platform::ModuleAPI* platform_api // Needs a contextual reference to four things: // Timing, Input, Bitmap Buffer -using UpdateAndRenderFn = void ( f32 delta_time, InputState* input, OffscreenBuffer* back_buffer, Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread ); +using UpdateAndRenderFn = void ( f32 delta_time + , InputState* input, OffscreenBuffer* back_buffer + , Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread ); // Audio timing is complicated, processing samples must be done at a different period from the rest of the engine's usual update. // IMPORTANT: This has very tight timing, and cannot be more than a millisecond in execution. // TODO(Ed) : Reduce timing pressure on performance by measuring it or pinging its time. -using UpdateAudioFn = void ( f32 delta_time, AudioBuffer* audio_buffer, Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread ); +using UpdateAudioFn = void ( f32 delta_time + , AudioBuffer* audio_buffer + , Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread ); struct ModuleAPI { diff --git a/project/engine/test_samples.cpp b/project/engine/test_samples.cpp index 664ac95..18ce687 100644 --- a/project/engine/test_samples.cpp +++ b/project/engine/test_samples.cpp @@ -1,3 +1,9 @@ +#if INTELLISENSE_DIRECTIVES +#include "engine.hpp" +#endif + +NS_ENGINE_BEGIN + using GetSoundSampleValueFn = s16( EngineState* state, AudioBuffer* sound_buffer ); internal s16 @@ -76,3 +82,39 @@ render_weird_graident(OffscreenBuffer* buffer, u32 x_offset, u32 y_offset ) row += buffer->pitch; } } + +internal +void render_player( OffscreenBuffer* buffer, s32 pos_x, s32 pos_y ) +{ + u8* end_of_buffer = rcast(u8*, buffer->memory) + - buffer->bytes_per_pixel * buffer->width + + buffer->pitch * buffer->height; + + s32 top = pos_y; + s32 bottom = pos_y + 10; + + u32 color = 0xFFFFFFFF; + + for ( s32 coord_x = pos_x; coord_x < (pos_x+ 10); ++ coord_x ) + { + u8* + pixel_byte = rcast(u8*, buffer->memory); + pixel_byte += coord_x * buffer->bytes_per_pixel; + pixel_byte += top * buffer->pitch; + + for ( s32 coord_y = top; coord_y < bottom; ++ coord_y ) + { + if ( pixel_byte < buffer->memory || pixel_byte >= end_of_buffer ) + continue; + + s32* pixel = rcast(s32*, pixel_byte); + *pixel = color; + + + + pixel_byte += buffer->pitch; + } + } +} + +NS_ENGINE_END diff --git a/project/handmade.cpp b/project/handmade.cpp index 9bcbd36..fe3871a 100644 --- a/project/handmade.cpp +++ b/project/handmade.cpp @@ -1,8 +1,13 @@ /* - Hnadmade Hero game code layer. +Hnadmade Hero game code layer. + +Note: +There is not enough code yet in the engine layer to do this separation +to a game module. */ -#pragma once - +#if INTELLISENSE_DIRECTIVES #include "engine/engine.hpp" +#endif + diff --git a/project/handmade.hpp b/project/handmade.hpp index d2321d7..55a4579 100644 --- a/project/handmade.hpp +++ b/project/handmade.hpp @@ -1,6 +1,7 @@ #pragma once - +#if INTELLISENSE_DIRECTIVES #include "engine/engine.hpp" +#endif #define NS_HANDMADE_BEGIN namespace hh { #define NS_HANDMADE_END } @@ -100,3 +101,4 @@ struct GameState }; NS_HANDMADE_END + diff --git a/project/handmade_engine.cpp b/project/handmade_engine.cpp index 9e52687..7f0a77b 100644 --- a/project/handmade_engine.cpp +++ b/project/handmade_engine.cpp @@ -1,6 +1,26 @@ -#include "platform/compiler_ignores.hpp" -#include "platform/grime.hpp" +/* +Handmade Engine Translation Unit +*/ -#if Build_Unity -# include "engine/engine.cpp" -#endif +#include "platform/compiler_ignores.hpp" + +#include // TEMP +#include // TEMP + +#include "platform/grime.hpp" +#include "platform/macros.hpp" +#include "platform/generics.hpp" +#include "platform/math_constants.hpp" +#include "platform/types.hpp" +#include "platform/intrinsics.hpp" +#include "platform/strings.hpp" +#include "platform/context.hpp" +#include "platform/platform.hpp" + +#include "engine.hpp" +#include "engine_to_platform_api.hpp" + +// Game layer headers +#include "handmade.hpp" + +#include "engine.cpp" diff --git a/project/handmade_win32.cpp b/project/handmade_win32.cpp index efaf60b..69dc710 100644 --- a/project/handmade_win32.cpp +++ b/project/handmade_win32.cpp @@ -1,5 +1,27 @@ -#include "platform/compiler_ignores.hpp" +/* +Handmade Win32 Platform Translation Unit +*/ -#if Build_Unity -#include "platform/win32/win32_platform.cpp" -#endif +#include "compiler_ignores.hpp" + +#include // TEMP +#include // TEMP + +#include "grime.hpp" +#include "macros.hpp" +#include "generics.hpp" +#include "math_constants.hpp" +#include "types.hpp" +#include "intrinsics.hpp" +#include "strings.hpp" +#include "context.hpp" +#include "platform.hpp" + +// Engine layer headers +#include "engine/engine.hpp" +#include "engine/engine_to_platform_api.hpp" +#include "gen/engine_symbol_table.hpp" + +#include "jsl.hpp" // Using this to get dualsense controllers +#include "win32/win32.hpp" +#include "win32/win32_platform.cpp" diff --git a/project/platform/context.hpp b/project/platform/context.hpp index a99ec13..9a8a1d1 100644 --- a/project/platform/context.hpp +++ b/project/platform/context.hpp @@ -1,5 +1,4 @@ -#include "platform.hpp" - +#pragma once struct Context { diff --git a/project/platform/intrinsics.hpp b/project/platform/intrinsics.hpp new file mode 100644 index 0000000..bb7ca01 --- /dev/null +++ b/project/platform/intrinsics.hpp @@ -0,0 +1,47 @@ +#pragma once + +#if INTELLISENSE_DIRECTIVES +#include +#endif + +// TODO(Ed) : Convert all of these to platform-efficient versions + +inline +s32 floor_f32_to_s32( f32 value ) +{ + s32 result = scast(s32, floorf( value )); + return result; +} + +inline +s32 round_f32_to_s32( f32 value ) +{ + s32 result = scast(s32, value + 0.5f); + return result; +} + +inline +s32 truncate_f32_to_s32( f32 value ) +{ + s32 result = scast(s32, value); + return result; +} + +inline +f32 sine( f32 angle ) +{ + f32 result = sinf( angle ); + return result; +} + +f32 cosine( f32 angle ) +{ + f32 result = cosf( angle ); + return result; +} + +f32 arc_tangent( f32 Y, f32 X ) +{ + f32 result = atan2f( Y, X ); + return result; +} diff --git a/project/platform/jsl.hpp b/project/platform/jsl.hpp index f0d71f9..992a562 100644 --- a/project/platform/jsl.hpp +++ b/project/platform/jsl.hpp @@ -1,8 +1,8 @@ +#pragma once + // Joyshock grime wrapper - -#include "grime.hpp" - // JoyShock does not provide a proper c-linkage definition for its structs, so we have to push this warning ignore. + #ifdef COMPILER_CLANG # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wreturn-type-c-linkage" diff --git a/project/platform/math_constants.hpp b/project/platform/math_constants.hpp index e80e69e..2724473 100644 --- a/project/platform/math_constants.hpp +++ b/project/platform/math_constants.hpp @@ -1,5 +1,7 @@ #pragma once +// TODO(Ed) : Make a constant per type? + # define EPSILON 1.19209290e-7f # define ZERO 0.0f # define ONE 1.0f diff --git a/project/platform/platform.hpp b/project/platform/platform.hpp index 94da947..2253e15 100644 --- a/project/platform/platform.hpp +++ b/project/platform/platform.hpp @@ -8,7 +8,8 @@ #pragma once -// TODO(Ed) : REMOVE THESE WHEN HE GETS TO THEM +#if INTELLISENSE_DIRECTIVES +// TODO(Ed) : REMOVE THESE WHEN CASEY GETS TO THEM #include // TODO : Implement math ourselves #include // TODO : Implement output logging ourselves @@ -17,8 +18,10 @@ #include "generics.hpp" #include "math_constants.hpp" #include "types.hpp" +#include "intrinsics.hpp" #include "strings.hpp" #include "context.hpp" +#endif #define NS_PLATFORM_BEGIN namespace platform { #define NS_PLATFORM_END } diff --git a/project/platform/strings.hpp b/project/platform/strings.hpp index 484721f..12020ce 100644 --- a/project/platform/strings.hpp +++ b/project/platform/strings.hpp @@ -1,5 +1,4 @@ -#include "macros.hpp" -#include "types.hpp" +#pragma once void str_append( u32 dest_len, char* dest, u32 src_len, char const* src ); void str_concat( u32 dest_size, char* dest diff --git a/project/platform/win32/win32.hpp b/project/platform/win32/win32.hpp index f4a2086..7ad4f86 100644 --- a/project/platform/win32/win32.hpp +++ b/project/platform/win32/win32.hpp @@ -35,11 +35,6 @@ // # define CONST const // #endif -// SAL BS -#ifndef _In_ -# define _In_ -#endif - #define NS_WIN32_BEGIN namespace win32 { #define NS_WIN32_END } @@ -130,18 +125,6 @@ ProcSignature* get_procedure_from_library( HMODULE library_module, char const* s } #pragma region XInput -WIN_LIB_API DWORD WINAPI XInputGetState -( - DWORD dwUserIndex, // Index of the gamer associated with the device - XINPUT_STATE* pState // Receives the current state -); - -WIN_LIB_API DWORD WINAPI XInputSetState -( - DWORD dwUserIndex, // Index of the gamer associated with the device - XINPUT_VIBRATION* pVibration // The vibration information to send to the controller -); - DWORD WINAPI xinput_get_state_stub( DWORD dwUserIndex, XINPUT_STATE* pVibration ) { do_once_start OutputDebugStringA( "xinput_get_state stubbed!\n"); diff --git a/project/platform/win32/win32_audio.cpp b/project/platform/win32/win32_audio.cpp index 3f04a73..cddf21e 100644 --- a/project/platform/win32/win32_audio.cpp +++ b/project/platform/win32/win32_audio.cpp @@ -1,7 +1,11 @@ -#include "platform/platform.hpp" +#if INTELLISENSE_DIRECTIVES +#include "platform.hpp" +#include "engine/engine.hpp" #include "win32.hpp" +#endif NS_PLATFORM_BEGIN +using namespace win32; // TODO : This will def need to be looked over. struct DirectSoundBuffer diff --git a/project/platform/win32/win32_input.cpp b/project/platform/win32/win32_input.cpp index b162c57..7a44a00 100644 --- a/project/platform/win32/win32_input.cpp +++ b/project/platform/win32/win32_input.cpp @@ -1,15 +1,19 @@ -#include "platform/platform.hpp" -#include "platform/jsl.hpp" +#if INTELLISENSE_DIRECTIVES +#include "platform.hpp" +#include "engine/engine.hpp" +#include "jsl.hpp" #include "win32.hpp" +#endif NS_PLATFORM_BEGIN +using namespace win32; // Max controllers for the platform layer and thus for all other layers is 4. (Sanity and xinput limit) constexpr u32 Max_Controllers = 4; -using JSL_DeviceHandle = int; +using JSL_DeviceHandle = int; using EngineXInputPadStates = engine::XInputPadState[ Max_Controllers ]; -using EngineDSPadStates = engine::DualsensePadState[Max_Controllers]; +using EngineDSPadStates = engine::DualsensePadState[Max_Controllers]; internal void input_process_digital_btn( engine::DigitalBtn* old_state, engine::DigitalBtn* new_state, u32 raw_btns, u32 btn_flag ) diff --git a/project/platform/win32/win32_platform.cpp b/project/platform/win32/win32_platform.cpp index c3cd545..139a400 100644 --- a/project/platform/win32/win32_platform.cpp +++ b/project/platform/win32/win32_platform.cpp @@ -1,3 +1,11 @@ +#if INTELLISENSE_DIRECTIVES +#include "platform/platform.hpp" +#include "engine/engine.hpp" +#include "engine/engine_to_platform_api.hpp" +#include "gen/engine_symbol_table.hpp" +#include "win32.hpp" +#include "jsl.hpp" +#endif /* TODO : This is not a final platform layer @@ -17,17 +25,6 @@ - GetKeyboardLayout (for French keyboards, international WASD support) */ -// Platform Layer headers -#include "platform/platform.hpp" -#include "platform/jsl.hpp" // Using this to get dualsense controllers -#include "win32.hpp" - -// Engine layer headers -#include "engine/engine.hpp" -#include "engine/engine_to_platform_api.hpp" - -#include "gen/engine_symbol_table.hpp" - NS_PLATFORM_BEGIN using namespace win32; diff --git a/project/platform/win32/win32_platform_api.cpp b/project/platform/win32/win32_platform_api.cpp index 36d6ce0..a00253e 100644 --- a/project/platform/win32/win32_platform_api.cpp +++ b/project/platform/win32/win32_platform_api.cpp @@ -1,6 +1,8 @@ -#include "platform/platform.hpp" -#include "platform/jsl.hpp" +#if INTELLISENSE_DIRECTIVES +#include "platform.hpp" +#include "jsl.hpp" #include "win32.hpp" +#endif NS_PLATFORM_BEGIN diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 6a68fa6..867575d 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -48,6 +48,7 @@ if ( $args ) { $args | ForEach-Object { write-host "Building HandmadeHero with $vendor" $path_project = Join-Path $path_root 'project' +$path_scripts = Join-Path $path_root 'scripts' $path_data = Join-Path $path_root 'data' $path_binaries = Join-Path $path_data 'binaries' $path_deps = Join-Path $path_project 'dependencies' @@ -95,8 +96,6 @@ $compiler_args = @( $flag_wall $flag_warnings_as_errors $flag_optimize_intrinsics - - ($flag_define + 'Build_Unity=1' ) ) if ( $dev ) { @@ -118,6 +117,9 @@ function build-engine if ( $verbose ) { Write-Host "Deleted $file" -ForegroundColor Green } } + $local:includes = $script:includes + $includes += $path_engine + $local:compiler_args = $script:compiler_args $compiler_args += ($flag_define + 'Build_DLL=1' ) @@ -231,7 +233,7 @@ function build-engine $unit = Join-Path $path_codegen 'engine_postbuild_gen.cpp' $executable = Join-Path $path_build 'engine_postbuild_gen.exe' - build-simple $path_build $includes $compiler_args $linker_args $unit $executable + build-simple $path_build $local:includes $compiler_args $linker_args $unit $executable Push-Location $path_build $time_taken = Measure-Command { @@ -267,6 +269,9 @@ function build-platform New-Item $path_platform_gen -ItemType Directory } + $local:includes = $script:includes + $includes += $path_platform + $local:compiler_args = @() $compiler_args += ( $flag_define + 'GEN_TIME' ) @@ -333,12 +338,14 @@ if ( (Test-Path $path_jsl_dll) -eq $false ) } #endregion Handmade Runtime +push-location $path_scripts $include = @( '*.cpp' '*.hpp' ) format-cpp $path_gen $include format-cpp (Join-Path $path_platform 'gen' ) $include +pop-location Pop-Location #endregion Building diff --git a/scripts/handmade.rdbg b/scripts/handmade.rdbg index e2544a7..07fd563 100644 Binary files a/scripts/handmade.rdbg and b/scripts/handmade.rdbg differ diff --git a/scripts/helpers/configure_toolchain.ps1 b/scripts/helpers/configure_toolchain.ps1 index 02bb99f..4ea05f1 100644 --- a/scripts/helpers/configure_toolchain.ps1 +++ b/scripts/helpers/configure_toolchain.ps1 @@ -169,6 +169,7 @@ if ( $vendor -match "clang" ) $pdb = $binary -replace '\.(exe|dll)$', "_$(get-random).pdb" $compiler_args += @( + ( $flag_define + 'INTELLISENSE_DIRECTIVES=0' ), $flag_no_color_diagnostics, $flag_exceptions_disabled, $flag_target_arch, $target_arch, @@ -294,6 +295,7 @@ if ( $vendor -match "msvc" ) $compiler_args += @( $flag_nologo, + ( $flag_define + 'INTELLISENSE_DIRECTIVES=0'), # $flag_all_cpp, $flag_exceptions_disabled, ( $flag_define + '_HAS_EXCEPTIONS=0' ),