Files
Aerofoil/GpShell/GpAppEnvironment.cpp

91 lines
2.4 KiB
C++
Raw Normal View History

#include "GpAppEnvironment.h"
#include "GpAppInterface.h"
2019-12-31 05:20:07 -05:00
#include "GpDisplayDriverTickStatus.h"
2019-12-21 18:40:17 -05:00
#include "GpFontHandlerFactory.h"
#include "HostSuspendCallArgument.h"
2019-12-31 05:20:07 -05:00
#include "IGpDisplayDriver.h"
2019-12-29 17:39:19 -05:00
#include "IGpInputDriver.h"
#include <assert.h>
GpAppEnvironment::GpAppEnvironment()
2021-03-26 17:05:38 -04:00
: m_displayDriver(nullptr)
, m_audioDriver(nullptr)
2019-12-29 17:39:19 -05:00
, m_inputDrivers(nullptr)
, m_numInputDrivers(0)
2019-12-21 18:40:17 -05:00
, m_fontHandler(nullptr)
2019-12-24 02:35:24 -05:00
, m_vosEventQueue(nullptr)
, m_systemServices(nullptr)
, m_suspendCallID(PortabilityLayer::HostSuspendCallID_Unknown)
, m_suspendArgs(nullptr)
, m_suspendReturnValue(nullptr)
{
}
GpAppEnvironment::~GpAppEnvironment()
{
}
void GpAppEnvironment::Init()
{
GpAppInterface_Get()->ApplicationInit();
}
2021-03-26 17:05:38 -04:00
void GpAppEnvironment::Run()
{
2021-03-26 17:05:38 -04:00
InitializeApplicationState();
GpAppInterface_Get()->ApplicationMain();
}
2021-03-26 17:05:38 -04:00
2019-12-21 18:40:17 -05:00
void GpAppEnvironment::Render()
{
GpAppInterface_Get()->PL_Render(m_displayDriver);
}
bool GpAppEnvironment::AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualheight, float &pixelScaleX, float &pixelScaleY)
{
return GpAppInterface_Get()->PL_AdjustRequestedResolution(physicalWidth, physicalHeight, virtualWidth, virtualheight, pixelScaleX, pixelScaleY);
}
void GpAppEnvironment::SetDisplayDriver(IGpDisplayDriver *displayDriver)
{
m_displayDriver = displayDriver;
}
void GpAppEnvironment::SetAudioDriver(IGpAudioDriver *audioDriver)
{
m_audioDriver = audioDriver;
}
2019-12-29 17:39:19 -05:00
void GpAppEnvironment::SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers)
{
m_inputDrivers = inputDrivers;
m_numInputDrivers = numDrivers;
}
2020-09-12 14:01:51 -04:00
void GpAppEnvironment::SetFontHandler(IGpFontHandler *fontHandler)
2019-12-21 18:40:17 -05:00
{
m_fontHandler = fontHandler;
}
2019-12-24 02:35:24 -05:00
void GpAppEnvironment::SetVOSEventQueue(GpVOSEventQueue *eventQueue)
{
m_vosEventQueue = eventQueue;
}
void GpAppEnvironment::SetSystemServices(IGpSystemServices *systemServices)
{
m_systemServices = systemServices;
}
void GpAppEnvironment::InitializeApplicationState()
{
GpDriverCollection *drivers = GpAppInterface_Get()->PL_GetDriverCollection();
drivers->SetDriver<GpDriverIDs::kDisplay>(m_displayDriver);
drivers->SetDriver<GpDriverIDs::kAudio>(m_audioDriver);
drivers->SetDrivers<GpDriverIDs::kInput>(m_inputDrivers, m_numInputDrivers);
drivers->SetDriver<GpDriverIDs::kFont>(m_fontHandler);
drivers->SetDriver<GpDriverIDs::kEventQueue>(m_vosEventQueue);
}