camera movement & formatting

This commit is contained in:
Asuro
2025-02-12 01:24:28 +01:00
parent bf2371eca0
commit 03aecb6d44
18 changed files with 1316 additions and 574 deletions

View File

@@ -1,65 +1,67 @@
#include "Setup.h"
#include "Log.h"
#include "bx/timer.h"
#include "rendering/Rendering.h"
#include "Global.h"
#include "Instance.h"
#include "Log.h"
#include "Setup.h"
#include "bx/timer.h"
#include "rendering/Rendering.h"
namespace Game
{
class GameSetup
{
public:
GameRendering Rendering;
};
class GameSetup
{
public:
GameRendering Rendering;
};
namespace
{
GameSetup SetupInstance;
}
namespace
{
GameSetup SetupInstance;
}
void Setup(SharedData& shared)
{
Log("Game Setup Start!");
void Setup(SharedData& shared)
{
Log("Game Setup Start!");
if (shared.Game.PermanentStorage == nullptr)
{
Log("Game memory not initialized!!");
return;
}
if (shared.Game.EntityStorage == nullptr)
{
Log("Entity memory not initialized!");
return;
}
if (shared.Game.PermanentStorageSize < sizeof(GameInstance))
{
Log("Game memory too small! %u < %u", shared.Game.PermanentStorageSize, sizeof(GameInstance));
return;
}
GameInstance& instance = *reinterpret_cast<GameInstance*>(shared.Game.PermanentStorage);
if (sizeof(GameInstance) != instance.Size)
{
Log("Game instance size changed, resetting!");
instance = {};
}
SetShared(shared);
SetInstance(instance);
SetupInstance.Rendering.Setup();
instance.GameLevel.Setup(shared.Game);
instance.IsInitialized = true;
}
if (shared.Game.PermanentStorage == nullptr)
{
Log("Game memory not initialized!!");
return;
}
if (shared.Game.EntityStorage == nullptr)
{
Log("Entity memory not initialized!");
return;
}
if (shared.Game.PermanentStorageSize < sizeof(GameInstance))
{
Log("Game memory too small! %u < %u", shared.Game.PermanentStorageSize, sizeof(GameInstance));
return;
}
GameInstance& instance = *reinterpret_cast<GameInstance*>(shared.Game.PermanentStorage);
if (sizeof(GameInstance) != instance.Size)
{
Log("Game instance size changed, resetting!");
instance = {};
}
SetShared(shared);
SetInstance(instance);
SetupInstance.Rendering.Setup();
instance.GameLevel.Setup(shared.Game);
instance.IsInitialized = true;
}
void Update()
{
++GetInstance().FrameCounter;
GetInstance().Now = (bx::getHPCounter() - GetInstance().StartTime) / (double)(bx::getHPFrequency());
SetupInstance.Rendering.Update();
}
void Update()
{
++GetInstance().FrameCounter;
double newNow = (bx::getHPCounter() - GetInstance().StartTime) / (double)(bx::getHPFrequency());
GetInstance().Delta = newNow - GetInstance().Now;
GetInstance().Now = newNow;
SetupInstance.Rendering.Update();
}
void Shutdown()
{
Log("Shutdown");
SetupInstance.Rendering.Shutdown();
}
}
void Shutdown()
{
Log("Shutdown");
SetupInstance.Rendering.Shutdown();
}
} // namespace Game