Day 31 complete

This commit is contained in:
Edward R. Gonzalez 2023-10-07 02:33:39 -04:00
parent cb3c71705f
commit dd00713c9e
29 changed files with 340 additions and 159 deletions

View File

@ -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"
}

View File

@ -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",

View File

@ -8,8 +8,8 @@
<ShowEmptyFolders>true</ShowEmptyFolders>
<IsVirtual>false</IsVirtual>
<IsFolder>false</IsFolder>
<BuildCommand>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev debug engine</BuildCommand>
<RebuildCommand>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev debug platform</RebuildCommand>
<BuildCommand>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev engine</BuildCommand>
<RebuildCommand>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/build.ps1 msvc dev platform</RebuildCommand>
<BuildFileCommand></BuildFileCommand>
<CleanCommand>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(WorkspaceDirectory)/scripts/clean.ps1</CleanCommand>
<BuildWorkingDirectory></BuildWorkingDirectory>
@ -44,6 +44,7 @@
<Define>GEN_TIME</Define>
<Define>Build_Debug</Define>
<Define>Build_Development</Define>
<Define>INTELLISENSE_DIRECTIVES=1</Define>
</Defines>
<ConfigProperties>
<ConfigAndPlatform>
@ -61,10 +62,11 @@
<Defines></Defines>
<ForceIncludes></ForceIncludes>
</ConfigAndPlatform>
<Config>
<Name>Debug</Name>
<ConfigAndPlatform>
<Name>Dev:x64</Name>
<Defines></Defines>
</Config>
<ForceIncludes></ForceIncludes>
</ConfigAndPlatform>
<Config>
<Name>Dev</Name>
<Defines></Defines>

View File

@ -15,12 +15,12 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Development|x64'">
<IncludePath>$(ProjectDir)project;$(IncludePath);</IncludePath>
<IncludePath>$(ProjectDir)project;$(ProjectDir)project\engine;$(ProjectDir)project\platform;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)data;$(windir)System32;$(LibraryPath)</LibraryPath>
<NMakeBuildCommandLine>pwsh -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)scripts\build.ps1 msvc dev engine</NMakeBuildCommandLine>
<NMakeCleanCommandLine>pwsh ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(ProjectDir)scripts\clean.ps1</NMakeCleanCommandLine>
<NMakePreprocessorDefinitions>GEN_TIME;Build_Development;Build_Debug;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<ExternalIncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);$(UniversalCRT_IncludePath);</ExternalIncludePath>
<NMakePreprocessorDefinitions>GEN_TIME;INTELLISENSE_DIRECTIVES;Build_Development;Build_Debug;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<ExternalIncludePath>$(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</ExternalIncludePath>
<NMakeReBuildCommandLine>
</NMakeReBuildCommandLine>
</PropertyGroup>
@ -42,7 +42,6 @@
<ClInclude Include="project\platform\platform.hpp" />
<ClInclude Include="project\platform\strings.hpp" />
<ClInclude Include="project\platform\types.hpp" />
<ClInclude Include="project\platform\win32.hpp" />
<ClInclude Include="project\platform\win32\win32.hpp" />
</ItemGroup>
<ItemGroup>
@ -57,7 +56,6 @@
<ClCompile Include="project\platform\win32\win32_input.cpp" />
<ClCompile Include="project\platform\win32\win32_platform.cpp" />
<ClCompile Include="project\platform\win32\win32_platform_api.cpp" />
<ClCompile Include="project\platform\win32_platform.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="docs\Day 001.md" />
@ -75,10 +73,22 @@
<None Include="docs\Day 020.md" />
<None Include="docs\Day 021.md" />
<None Include="docs\Day 022.md" />
<None Include="docs\Day 023.md" />
<None Include="docs\Day 024.md" />
<None Include="docs\Day 025.md" />
<None Include="docs\Day 027.md" />
<None Include="docs\Day 030.md" />
<None Include="docs\Day 031.md" />
<None Include="scripts\.clang-format" />
<None Include="scripts\build.ps1" />
<None Include="scripts\clean.ps1" />
<None Include="scripts\genccp.natstepfilter" />
<None Include="scripts\handmade.natstepfilter" />
<None Include="scripts\helpers\configure_toolchain.ps1" />
<None Include="scripts\helpers\devshell.ps1" />
<None Include="scripts\helpers\format_cpp.psm1" />
<None Include="scripts\helpers\target_arch.psm1" />
<None Include="scripts\rebuild.ps1" />
<None Include="scripts\update_deps.ps1" />
</ItemGroup>
<ItemGroup>
@ -86,6 +96,10 @@
<Content Include="project\gen\Readme.md" />
<Content Include="scripts\rebuild.ps1" />
</ItemGroup>
<ItemGroup>
<Natvis Include="scripts\gencpp.natvis" />
<Natvis Include="scripts\handmade.natvis" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Development|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>

26
docs/Day 031.md Normal file
View File

@ -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.

25
project/Readme.md Normal file
View File

@ -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`

View File

@ -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");

View File

@ -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

View File

@ -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;

View File

@ -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
{

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <math.h> // TEMP
#include <stdio.h> // 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"

View File

@ -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 <math.h> // TEMP
#include <stdio.h> // 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"

View File

@ -1,5 +1,4 @@
#include "platform.hpp"
#pragma once
struct Context
{

View File

@ -0,0 +1,47 @@
#pragma once
#if INTELLISENSE_DIRECTIVES
#include <math.h>
#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;
}

View File

@ -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"

View File

@ -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

View File

@ -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 <math.h> // TODO : Implement math ourselves
#include <stdio.h> // 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 }

View File

@ -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

View File

@ -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");

View File

@ -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

View File

@ -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 )

View File

@ -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;

View File

@ -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

View File

@ -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

Binary file not shown.

View File

@ -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' ),