Added a basic MemoryArena.
Added one scratch, one engine and one game arena. Converted the game alloc to arena + the display stuff. WIP Made using Antigravity+gemini
This commit is contained in:
@@ -4,11 +4,11 @@
|
||||
#undef max
|
||||
|
||||
#include <Core/HAL/Filesystem/Filesystem.h>
|
||||
#include <Core/JulietInit.h>
|
||||
#include <Core/Logging/LogManager.h>
|
||||
#include <Core/Logging/LogTypes.h>
|
||||
#include <Core/Memory/MemoryArena.h>
|
||||
#include <Entity/Entity.h>
|
||||
#include <Entity/EntityManager.h>
|
||||
#include <Graphics/Graphics.h>
|
||||
|
||||
// Test code
|
||||
namespace Game
|
||||
@@ -31,8 +31,21 @@ namespace Game
|
||||
|
||||
using namespace Juliet;
|
||||
|
||||
extern "C" __declspec(dllexport) void __cdecl GameInit()
|
||||
extern "C" JULIET_API void GameInit(GameInitParams* /*params*/)
|
||||
{
|
||||
// Example allocation in GameArena
|
||||
struct GameState
|
||||
{
|
||||
float TotalTime;
|
||||
int Score;
|
||||
};
|
||||
|
||||
auto* gameState = ArenaPushType<GameState>(GetGameArena());
|
||||
gameState->TotalTime = 0.0f;
|
||||
gameState->Score = 0;
|
||||
|
||||
printf("Game Arena Allocated: %p\n", gameState);
|
||||
|
||||
using namespace Game;
|
||||
|
||||
// Entity Use case
|
||||
@@ -41,8 +54,8 @@ extern "C" __declspec(dllexport) void __cdecl GameInit()
|
||||
Door* door = MakeEntity<Door>(manager, 10.0f, 2.0f);
|
||||
door->IsOpened = true;
|
||||
|
||||
Entity* ent = door->Base;
|
||||
[[maybe_unused]] Door* stillDoor = DownCast<Door>(ent);
|
||||
Entity* ent = door->Base;
|
||||
[[maybe_unused]] Door* stillDoor = DownCast<Door>(ent);
|
||||
Assert(door == stillDoor);
|
||||
|
||||
Rock* rock = MakeEntity<Rock>(manager, 1.f, 2.f);
|
||||
@@ -51,20 +64,14 @@ extern "C" __declspec(dllexport) void __cdecl GameInit()
|
||||
|
||||
printf("Door is %s\n", door->IsOpened ? "Opened" : "Closed");
|
||||
printf("Rock has %d health points\n", rock->Health);
|
||||
|
||||
// Have to manually free for now because im not using arenas or anything
|
||||
free(door->Base);
|
||||
free(door);
|
||||
free(rock->Base);
|
||||
free(rock);
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void __cdecl GameShutdown()
|
||||
extern "C" JULIET_API void __cdecl GameShutdown()
|
||||
{
|
||||
printf("Shutting down game...\n");
|
||||
}
|
||||
|
||||
extern "C" __declspec(dllexport) void __cdecl GameUpdate([[maybe_unused]] float deltaTime)
|
||||
extern "C" JULIET_API void __cdecl GameUpdate([[maybe_unused]] float deltaTime)
|
||||
{
|
||||
//printf("Updating game...\n");
|
||||
// printf("Updating game...\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user