HandmadeHero/project/engine/engine_to_platform_api.hpp

50 lines
1.5 KiB
C++
Raw Normal View History

2023-09-23 18:03:33 -07:00
/*
This represents the API only accessible to the platform layer to fullfill for the engine layer.
*/
#pragma once
2023-10-11 14:52:13 -07:00
#if INTELLISENSE_DIRECTIVES
#include "engine_module.hpp"
#endif
2023-09-26 14:26:35 -07:00
2023-09-23 18:03:33 -07:00
NS_ENGINE_BEGIN
2023-09-26 14:26:35 -07:00
using OnModuleRelaodFn = void( Memory* memory, platform::ModuleAPI* platform_api );
2023-10-11 14:52:13 -07:00
using StartupFn = void( OffscreenBuffer* back_buffer, Memory* memory, platform::ModuleAPI* platform_api );
2023-09-26 14:26:35 -07:00
using ShutdownFn = void( Memory* memory, platform::ModuleAPI* platform_api );
2023-09-23 18:03:33 -07:00
// Needs a contextual reference to four things:
2023-09-24 19:37:05 -07:00
// Timing, Input, Bitmap Buffer
2023-10-06 23:33:39 -07:00
using UpdateAndRenderFn = void ( f32 delta_time
, InputState* input, OffscreenBuffer* back_buffer
, Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread );
2023-09-24 19:37:05 -07:00
// 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.
2023-10-06 23:33:39 -07:00
using UpdateAudioFn = void ( f32 delta_time
, AudioBuffer* audio_buffer
, Memory* memory, platform::ModuleAPI* platform_api, ThreadContext* thread );
2023-09-26 14:26:35 -07:00
struct ModuleAPI
{
enum : u32
{
Sym_OnModuleReload,
Sym_Startup,
Sym_Shutdown,
Sym_UpdateAndRender,
Sym_UpdateAudio,
};
OnModuleRelaodFn* on_module_reload;
StartupFn* startup;
ShutdownFn* shutdown;
UpdateAndRenderFn* update_and_render;
UpdateAudioFn* update_audio;
b32 IsValid;
};
2023-09-23 18:03:33 -07:00
NS_ENGINE_END