#ifndef HANDMADE_H_SENTRY #define HANDMADE_H_SENTRY #include "core.h" /* --------------------------------------------------------------------- */ /* NOTE: Servcies that the platform layer provides to the game. */ /* --------------------------------------------------------------------- */ typedef struct thread_context { S32 Placeholder; } thread_context; #if BUILD_INTERNAL typedef struct debug_read_file_result { U32 ContentsSize; void *Contents; } debug_read_file_result; debug_read_file_result DEBUGPlatformReadEntireFile(thread_context *Thread, const char *Filename); B32 DEBUGPlatformWriteEntireFile(thread_context *Thread, const char *Filename, U32 MemorySize, void *Memory); void DEBUGPlatformFreeFileMemory(thread_context *Thread, void *Memory); #endif /* --------------------------------------------------------------------- */ /* NOTE: Servcies that the game provides to the platform layer. */ /* --------------------------------------------------------------------- */ typedef struct game_offscreen_buffer { /* Pixels are always 32-bit and have the bytes in BGRX * (little-endian). */ void *Memory; S32 Width; S32 Height; S32 BytesPerPixel; S32 Pitch; } game_offscreen_buffer; typedef struct game_sound_output_buffer { S32 SamplesPerSecond; S32 SampleCount; S16 *Samples; } game_sound_output_buffer; typedef struct game_button_state { S32 HalfTransitionCount; B32 EndedDown; } game_button_state; typedef struct game_controller_input { B32 IsConnected; B32 IsAnalog; F32 StickAverageX; F32 StickAverageY; union { game_button_state Buttons[12]; struct { game_button_state MoveUp; game_button_state MoveDown; game_button_state MoveLeft; game_button_state MoveRight; game_button_state ActionUp; game_button_state ActionDown; game_button_state ActionLeft; game_button_state ActionRight; game_button_state LeftShoulder; game_button_state RightShoulder; game_button_state Start; game_button_state Back; /* NOTE: All buttons must be added above this line. */ game_button_state Terminator; } buttons; } u; } game_controller_input; typedef struct game_input { game_button_state MouseButtons[5]; S32 MouseX, MouseY, MouseZ; /* NOTE: MouseZ is the wheel. */ F32 dtForFrame; game_controller_input Controllers[5]; } game_input; game_controller_input *GetController(game_input *Input, S32 ControllerIndex) { game_controller_input *Result; ASSERT((U32)ControllerIndex < ARRAY_SIZE(Input->Controllers)); Result = &(Input->Controllers[ControllerIndex]); return Result; } typedef struct game_memory { B32 IsInitialized; U64 PermanentStorageSize; void *PermanentStorage; /* WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.) */ U64 TransientStorageSize; void *TransientStorage; /* WARNING: This memory is REQUIRED to be zero initialized!!! (Done by the OS layer.) */ #if BUILD_INTERNAL debug_read_file_result (*DEBUGPlatformReadEntireFile)( thread_context *Thread,const char *); B32 (*DEBUGPlatformWriteEntireFile)(thread_context *Thread, const char *, U32, void *); void (*DEBUGPlatformFreeFileMemory)(thread_context *Thread, void *); #endif } game_memory; /*typedef struct game_clocks { U64 Ticks; F32 SecondsElapsed; } game_clocks;*/ void UpdateAndRender(thread_context *Thread, game_memory *Memory, game_input *Input, game_offscreen_buffer *Buffer, game_sound_output_buffer *SoundBuffer); /* * */ typedef struct game_state { F32 PlayerX; F32 PlayerY; } game_state; #endif