Using memory arena in the game that supports hot reload
This commit is contained in:
+5
-16
@@ -87,17 +87,16 @@ using namespace Juliet;
|
||||
|
||||
namespace
|
||||
{
|
||||
using GameInit_t = void (*)(GameInitParams*);
|
||||
using GameShutdown_t = void (*)(void);
|
||||
using GameUpdate_t = void (*)(float deltaTime);
|
||||
using GameUpdate_t = void (*)(GameData* params, float deltaTime);
|
||||
struct GameFunctionTable
|
||||
{
|
||||
GameInit_t Init = nullptr;
|
||||
GameShutdown_t Shutdown = nullptr;
|
||||
GameUpdate_t Update = nullptr;
|
||||
} Game;
|
||||
GameData Data;
|
||||
|
||||
const char* GameFunctionTable[] = { "GameInit", "GameShutdown", "GameUpdate" };
|
||||
const char* GameFunctionTable[] = { "GameShutdown", "GameUpdate" };
|
||||
|
||||
LightID RedLightID = 0;
|
||||
LightID BlueLightID = 0;
|
||||
@@ -178,13 +177,7 @@ void JulietApplication::Init(NonNullPtr<Arena>)
|
||||
GameCode.FunctionCount = ArraySize(GameFunctionTable);
|
||||
GameCode.FunctionNames = GameFunctionTable;
|
||||
InitHotReloadCode(GameCode, ConstString("Game.dll"), ConstString("Game_Temp.dll"), ConstString("lock.tmp"));
|
||||
if ((Running = GameCode.IsValid))
|
||||
{
|
||||
GameInitParams params;
|
||||
params.GameArena = GameArena = ArenaAllocate({} JULIET_DEBUG_ONLY(, "Game Arena"));
|
||||
params.ScratchArena = GameScratchArena = ArenaAllocate({} JULIET_DEBUG_ONLY(, "Scratch Arena"));
|
||||
Game.Init(¶ms);
|
||||
}
|
||||
Running = GameCode.IsValid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,8 +422,6 @@ void JulietApplication::Update()
|
||||
ImGui::End();
|
||||
#endif
|
||||
|
||||
ArenaClear(GameScratchArena);
|
||||
|
||||
Vector3 redLightPos = { 5.0f, 5.0f, 2.0f };
|
||||
Vector3 blueLightPos = { -5.0f, 0.0f, 2.0f };
|
||||
|
||||
@@ -497,7 +488,7 @@ void JulietApplication::Update()
|
||||
DebugDisplay_DrawSphere(blueLightPos, 0.5f, { 0.0f, 0.0f, 1.0f, 1.0f }, true);
|
||||
DebugDisplay_DrawSphere(redLightPos, 0.5f, { 1.0f, 0.0f, 0.0f, 1.0f }, true);
|
||||
|
||||
Game.Update(0.0f);
|
||||
Game.Update(&Data, 0.0f);
|
||||
|
||||
if (ShouldReloadCode(GameCode))
|
||||
{
|
||||
@@ -545,8 +536,6 @@ void JulietApplication::Update()
|
||||
Debug::DebugDrawMemoryArena();
|
||||
#endif
|
||||
}
|
||||
|
||||
ArenaClear(GameScratchArena);
|
||||
}
|
||||
|
||||
void JulietApplication::OnPreRender(CommandList* /*cmd*/) {}
|
||||
|
||||
@@ -43,8 +43,6 @@ class JulietApplication : public Juliet::IApplication
|
||||
Juliet::HotReloadCode GameCode = {};
|
||||
Juliet::GraphicsPipeline* GraphicsPipeline = {};
|
||||
Juliet::Texture* DepthBuffer = {};
|
||||
Juliet::Arena* GameArena = nullptr;
|
||||
Juliet::Arena* GameScratchArena = nullptr;
|
||||
|
||||
int AutoCloseFrameCount = -1;
|
||||
bool Running = false;
|
||||
|
||||
Reference in New Issue
Block a user