metaforce/Runtime/MP1/MP1.cpp

124 lines
3.3 KiB
C++

#include "MP1.hpp"
#include "Graphics/Shaders/CModelShaders.hpp"
namespace urde
{
namespace MP1
{
class CMain* g_main = nullptr;
CMain::CMain(IFactory& resFactory, CSimplePool& resStore)
: m_globalObjects(resFactory, resStore)
{
g_main = this;
xe4_gameplayResult = EGameplayResult::Playing;
}
void CMain::RegisterResourceTweaks()
{
}
void CMain::ResetGameState()
{
}
void CMain::InitializeSubsystems(boo::IGraphicsDataFactory* factory,
boo::IGraphicsCommandQueue* cc,
boo::ITextureR* renderTex,
const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine)
{
CGraphics::InitializeBoo(factory, cc, renderTex);
CModelShaders::Initialize(storeMgr, factory);
CMoviePlayer::Initialize();
CLineRenderer::Initialize();
CElementGen::Initialize();
CAnimData::InitializeCache();
CDecalManager::Initialize();
}
void CMain::FillInAssetIDs()
{
}
void CMain::LoadAudio()
{
}
void CMain::Init(boo::IGraphicsDataFactory* factory,
boo::IGraphicsCommandQueue* cc,
boo::ITextureR* renderTex,
const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine)
{
InitializeSubsystems(factory, cc, renderTex, storeMgr, voiceEngine);
m_globalObjects.PostInitialize();
x70_tweaks.RegisterTweaks();
//g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
}
bool CMain::Proc()
{
xe8_b24_finished = m_archSupport.Update();
return xe8_b24_finished;
}
void CMain::Shutdown()
{
}
#if MP1_USE_BOO
int CMain::appMain(boo::IApplication* app)
{
zeus::detectCPU();
mainWindow = app->newWindow(_S("Metroid Prime 1 Reimplementation vZygote"), 1);
mainWindow->showWindow();
TOneStatic<CGameGlobalObjects> globalObjs;
InitializeSubsystems();
globalObjs->PostInitialize();
x70_tweaks.RegisterTweaks();
AddWorldPaks();
g_TweakManager->ReadFromMemoryCard("AudioTweaks");
FillInAssetIDs();
TOneStatic<CGameArchitectureSupport> archSupport;
mainWindow->setCallback(archSupport.GetAllocSpace());
boo::IGraphicsCommandQueue* gfxQ = mainWindow->getCommandQueue();
boo::SWindowRect windowRect = mainWindow->getWindowFrame();
boo::ITextureR* renderTex;
boo::GraphicsDataToken data = mainWindow->getMainContextDataFactory()->commitTransaction(
[&](boo::IGraphicsDataFactory::Context& ctx) -> bool
{
renderTex = ctx.newRenderTexture(windowRect.size[0], windowRect.size[1], true, true);
return true;
});
float rgba[4] = { 0.2f, 0.2f, 0.2f, 1.0f};
gfxQ->setClearColor(rgba);
while (!xe8_b24_finished)
{
xe8_b24_finished = archSupport->Update();
if (archSupport->isRectDirty())
{
const boo::SWindowRect& windowRect = archSupport->getWindowRect();
gfxQ->resizeRenderTexture(renderTex,
windowRect.size[0],
windowRect.size[1]);
}
gfxQ->setRenderTarget(renderTex);
gfxQ->clearTarget();
gfxQ->resolveDisplay(renderTex);
gfxQ->execute();
mainWindow->waitForRetrace();
}
return 0;
}
#endif
}
}