demotool/ui.cc
2017-11-24 09:51:05 +01:00

62 lines
1.3 KiB
C++

#include "externals.hh"
#include "common.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
{
Common::Init( );
new ((char*)&Instance_) UIData_( );
}
void UI::Shutdown( ) noexcept
{
((UIData_*)(char*)&Instance_)->~UIData_( );
Common::Shutdown( );
}
/*----------------------------------------------------------------------------*/
#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 ); }