mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2025-07-01 11:21:05 -07:00
Day 42 complete
Found and fixed bugs with gencpp when generating the vector math stuff.
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
#pragma warning( disable: 4711 ) // Support automatic inline expansion
|
||||
#pragma warning( disable: 4710 ) // Support automatic inline expansion
|
||||
#pragma warning( disable: 4805 ) // Support comparisons of s32 to bool.
|
||||
#pragma warning( disable: 5246 ) // Support for initialization of subobject without braces.
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
|
@ -8,3 +8,7 @@ void swap( Type& a, Type& b )
|
||||
a = b;
|
||||
b = temp;
|
||||
}
|
||||
|
||||
#define Zero( type ) tmpl_zero<type>()
|
||||
template< class Type >
|
||||
constexpr Type tmpl_zero();
|
||||
|
@ -7,11 +7,43 @@
|
||||
|
||||
// TODO(Ed) : Convert all of these to platform-efficient versions
|
||||
|
||||
//inline
|
||||
//s32 abs( s32 value )
|
||||
//{
|
||||
// return ;
|
||||
//}
|
||||
inline
|
||||
f32 abs( f32 value )
|
||||
{
|
||||
return fabsf(value);
|
||||
}
|
||||
|
||||
inline
|
||||
f32 sqrt( f32 value )
|
||||
{
|
||||
return sqrtf(value);
|
||||
}
|
||||
|
||||
inline
|
||||
s32 sqrt(s32 value) {
|
||||
if (value < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value == 0 || value == 1) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// Initial guess for the square root
|
||||
s32 current_estimate = value;
|
||||
s32 reciprocal_estimate = 1;
|
||||
// Second estimate based on the reciprocal of our current guess
|
||||
|
||||
// Tolerance level for convergence
|
||||
const s32 tolerance = 1;
|
||||
|
||||
while (current_estimate - reciprocal_estimate > tolerance) {
|
||||
current_estimate = (current_estimate + reciprocal_estimate) / 2;
|
||||
reciprocal_estimate = value / current_estimate;
|
||||
}
|
||||
|
||||
return current_estimate;
|
||||
}
|
||||
|
||||
inline
|
||||
s32 floor( f32 value )
|
||||
|
@ -155,7 +155,7 @@ void toggle_fullscreen( HWND window_handle )
|
||||
{
|
||||
MONITORINFO info = { sizeof(MONITORINFO) };
|
||||
HMONITOR monitor_handle = MonitorFromWindow( window_handle, MONITOR_DEFAULTTOPRIMARY );
|
||||
|
||||
|
||||
if ( GetWindowPlacement( window_handle, & Window_Position )
|
||||
&& GetMonitorInfoA( monitor_handle, & info ) )
|
||||
{
|
||||
@ -193,7 +193,7 @@ display_buffer_in_window( HDC device_context, s32 window_width, s32 window_heigh
|
||||
, s32 x, s32 y
|
||||
, s32 width, s32 height )
|
||||
{
|
||||
if ( (window_width % buffer->width ) == 0
|
||||
if ( (window_width % buffer->width ) == 0
|
||||
&& (window_height % buffer->height) == 0 )
|
||||
{
|
||||
// TODO(Ed) : Aspect ratio correction
|
||||
@ -202,10 +202,10 @@ display_buffer_in_window( HDC device_context, s32 window_width, s32 window_heigh
|
||||
, 0, 0, buffer->width, buffer->height
|
||||
, buffer->memory, & buffer->info
|
||||
, DIB_ColorTable_RGB, RO_Source_To_Dest );
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
s32 offset_x = 0;
|
||||
s32 offset_y = 0;
|
||||
|
||||
@ -348,14 +348,14 @@ main_window_callback( HWND handle
|
||||
while (ShowCursor(FALSE) >= 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case WM_NCMOUSEMOVE:
|
||||
{
|
||||
// Show the cursor when it's outside the window's client area (i.e., on the frame or elsewhere)
|
||||
while (ShowCursor(TRUE) < 0);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case WM_SETCURSOR:
|
||||
{
|
||||
if ( Show_Windows_Cursor )
|
||||
@ -581,9 +581,9 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
||||
Path_Scratch.concat( Path_Root, str_ascii("scratch") );
|
||||
Path_Scratch.ptr[ Path_Scratch.len ] = '\\';
|
||||
++ Path_Scratch.len;
|
||||
|
||||
|
||||
CreateDirectoryA( Path_Scratch, 0 );
|
||||
|
||||
|
||||
Path_Content.concat( Path_Root, str_ascii("content") );
|
||||
Path_Content.ptr[ Path_Content.len ] = '\\';
|
||||
++ Path_Content.len;
|
||||
@ -593,7 +593,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
||||
engine::Memory engine_memory {};
|
||||
{
|
||||
engine_memory.persistent_size = megabytes( 128 );
|
||||
// engine_memory.FrameSize = megabytes( 64 );
|
||||
// engine_memory.FrameSize = megabytes( 64 );
|
||||
engine_memory.transient_size = gigabytes( 2 );
|
||||
|
||||
u64 total_size = engine_memory.persistent_size
|
||||
@ -688,7 +688,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
|
||||
// window_class.hbrBackground = ;
|
||||
window_class.lpszMenuName = L"Handmade Hero!";
|
||||
window_class.lpszClassName = L"HandmadeHeroWindowClass";
|
||||
|
||||
|
||||
Show_Windows_Cursor = true;
|
||||
Windows_Cursor = LoadCursorW( 0, IDC_CROSS );
|
||||
Window_Position = {sizeof(WINDOWPLACEMENT)};
|
||||
|
Reference in New Issue
Block a user