Day 14 complete

This commit is contained in:
2023-09-18 20:16:40 -04:00
parent abe3066071
commit 3de4178fff
14 changed files with 214 additions and 49 deletions

View File

@ -97,7 +97,6 @@ struct SoundOutput
s32 LatencySampleCount;
};
HRESULT WINAPI DirectSoundCreate(LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter );
using DirectSoundCreateFn = HRESULT WINAPI (LPGUID lpGuid, LPDIRECTSOUND* ppDS, LPUNKNOWN pUnkOuter );
@ -511,6 +510,48 @@ WinMain(
{
using namespace win32;
// Memory
engine::Memory engine_memory {};
{
engine_memory.PersistentSize = megabytes( 64 );
// engine_memory.FrameSize = megabytes( 64 );
engine_memory.TransientSize = gigabytes( 2 );
u64 total_size = engine_memory.PersistentSize
// + engine_memory.FrameSize
+ engine_memory.TransientSize;
#if Build_Debug
void* Base_Address = (void*) terabytes( 1 );
// void* Frame_Address = (void*) terabytes( 2 );
// void* Transient_Address = (void*) terabytes( 2 );
#else
void* Base_Address = 0;
// void* Frame_Address = 0;
// void* Transient_Address = 0;
#endif
engine_memory.Persistent = VirtualAlloc( Base_Address, total_size
, MEM_Commit_Zeroed | MEM_Reserve, Page_Read_Write );
engine_memory.Transient = rcast( u8*, engine_memory.Persistent ) + engine_memory.PersistentSize;
#if 0
engine_memory.Frame = VirtualAlloc( 0, engine_memory.FrameSize
, MEM_Commit_Zeroed | MEM_Reserve, Page_Read_Write );
engine_memory.Transient = VirtualAlloc( 0, engine_memory.TransientSize
, MEM_Commit_Zeroed | MEM_Reserve, Page_Read_Write );
#endif
if ( engine_memory.Persistent == nullptr
// || ! engine_memory.Frame
|| engine_memory.Transient == nullptr )
{
// TODO : Diagnostic Logging
return -1;
}
}
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
WNDCLASSW window_class {};
@ -567,6 +608,8 @@ WinMain(
SoundBufferSamples = rcast( s16*, VirtualAlloc( 0, 48000 * 2 * sizeof(s16)
, MEM_Commit_Zeroed | MEM_Reserve, Page_Read_Write ));
assert( SoundBufferSamples );
sound_output.RunningSampleIndex = 0;
sound_output.LatencySampleCount = DS_SecondaryBuffer_SamplesPerSecond / 15;
// ds_clear_sound_buffer( & sound_output );
@ -599,8 +642,8 @@ WinMain(
using JSL_DeviceHandle = int;
u32 jsl_num_devices
// = JslConnectDevices();
= 0;
= JslConnectDevices();
// = 0;
JSL_DeviceHandle jsl_device_handles[4] {};
{
xinput_load_library_bindings();
@ -809,7 +852,7 @@ WinMain(
sound_buffer.SamplesPerSecond = DS_SecondaryBuffer_SamplesPerSecond;
sound_buffer.Samples = SoundBufferSamples;
engine::update_and_render( & input, rcast(engine::OffscreenBuffer*, & BackBuffer.Memory), & sound_buffer );
engine::update_and_render( & input, rcast(engine::OffscreenBuffer*, & BackBuffer.Memory), & sound_buffer, & engine_memory );
// Rendering
{

View File

@ -18,7 +18,7 @@
#define do_once() \
do \
{ \
static \
local_persist \
bool Done = false; \
if ( Done ) \
return; \
@ -29,7 +29,7 @@
#define do_once_start \
do \
{ \
static \
local_persist \
bool Done = false; \
if ( Done ) \
break; \
@ -41,3 +41,29 @@
#define array_count( array ) ( sizeof( array ) / sizeof( ( array )[0] ) )
// TODO(Ed) : Move to memory header eventually
#define kilobytes( x ) ( ( x ) * ( s64 )( 1024 ) )
#define megabytes( x ) ( kilobytes( x ) * ( s64 )( 1024 ) )
#define gigabytes( x ) ( megabytes( x ) * ( s64 )( 1024 ) )
#define terabytes( x ) ( gigabytes( x ) * ( s64 )( 1024 ) )
// TODO(Ed) : Move to debug header eventually
#if Build_Development
# define assert( expression ) \
if ( !( expression ) ) \
{ \
*( int* )0 = 0; \
}
// platform::assertion_failure( __FILE__, __LINE__, #expression );
#else
# define assert( expression )
#endif
// TODO(Ed) : Add this sauce later
#if 0
#define congrats( message )
#define ensure( condition, expression )
#define fatal( message )
#endif

View File

View File

@ -9,4 +9,3 @@
#include "generics.h"
#include "math_constants.h"
#include "types.h"

View File

@ -15,7 +15,7 @@
// #include "windows/file.h"
// #include "windows/io.h"
// #ifdef Build_Debug
// #if Build_Debug
// # include "windows/dbghelp.h"
// #endif