demotool/ui.cc

60 lines
1.2 KiB
C++
Raw Normal View History

#include "externals.hh"
#include "ui.hh"
#include "ui-app.hh"
#include "ui-odbg.hh"
#include "ui-profiling.hh"
#include "ui-shaders.hh"
#include "ui-sync.hh"
#include "ui-texture.hh"
namespace {
struct UIData_
{
T_UIApp window;
T_Profiler profiler;
T_TextureManager textures;
T_ShaderManager shaders;
T_OutputDebugger odbg;
T_UISync sync;
};
std::aligned_storage_t< sizeof( UIData_ ) , alignof( UIData_ ) > Instance_;
} // namespace <anon>
/*----------------------------------------------------------------------------*/
void UI::Init( ) noexcept
{
new ((char*)&Instance_) UIData_( );
}
void UI::Shutdown( ) noexcept
{
((UIData_*)(char*)&Instance_)->~UIData_( );
}
/*----------------------------------------------------------------------------*/
#define M_GET_( P ) ((UIData_*)(char*)&Instance_)->P
T_UIApp& UI::Main( ) noexcept
{ return M_GET_( window ); }
T_Profiler& UI::Profiler( ) noexcept
{ return M_GET_( profiler ); }
T_TextureManager& UI::Textures( ) noexcept
{ return M_GET_( textures ); }
T_ShaderManager& UI::Shaders( ) noexcept
{ return M_GET_( shaders ); }
T_OutputDebugger& UI::ODbg( ) noexcept
{ return M_GET_( odbg ); }
T_UISync& UI::Sync( ) noexcept
{ return M_GET_( sync ); }