RavEngine
Loading...
Searching...
No Matches
RavEngine::App Class Reference
Collaboration diagram for RavEngine::App:
[legend]

Classes

struct  AudioBitsetUnpack
 

Public Member Functions

virtual void OnFatal (const std::string_view msg)
 
virtual void OnDropAudioWorklets (uint32_t ndropped)
 
virtual bool NeedsAudio () const
 
bool GetAudioActive () const
 
virtual bool NeedsNetworking () const
 
void Quit ()
 
int run (int argc, char **argv)
 
double GetCurrentTime ()
 
VirtualFilesystem & GetResources ()
 
RenderEngine & GetRenderEngine ()
 
auto & GetAudioPlayer ()
 
bool HasRenderEngine ()
 
template<typename T >
constexpr void DispatchMainThread (const T &f)
 
float CurrentTPS ()
 
float GetCurrentFPSScale () const
 
void SetRenderedWorld (Ref< World > newWorld)
 
void AddWorld (Ref< World > world)
 
void RemoveWorld (Ref< World > world)
 
void RemoveAllWorlds ()
 
void AddReplaceWorld (Ref< World > oldWorld, Ref< World > newWorld)
 
void SetWindowTitle (const char *title)
 
std::optional< Ref< World > > GetWorldByName (const std::string &name)
 
auto GetCurrentRenderWorld ()
 
void SwapCurrrentAudioSnapshot ()
 
void SwapRenderAudioSnapshotIfNeeded ()
 
AudioSnapshot * GetCurrentAudioSnapshot ()
 
AudioSnapshot * GetRenderAudioSnapshot ()
 
auto GetDevice ()
 
const auto & GetMainWindow () const
 

Static Public Member Functions

static AudioBitsetUnpack UnpackAudioBitset (uint8_t audioCurrentBitset)
 
static uint8_t RepackAudioBitset (AudioBitsetUnpack values)
 
static bool NewAudioAvailable (uint8_t currentBitset)
 

Public Attributes

bool wantsXR = false
 
const int numcpus = std::thread::hardware_concurrency()
 
tf::Executor executor
 
NetworkManager networkManager
 
Ref< InputManager > inputManager
 

Static Public Attributes

static constexpr float evalNormal = 60
 

Protected Member Functions

virtual AppConfig OnConfigure (int argc, char **argv)
 
virtual void OnStartup (int argc, char **argv)
 
virtual int OnShutdown ()
 

Protected Attributes

RGLDevicePtr device
 
std::unique_ptr< Window > window
 
RenderViewCollection mainWindowView
 
std::vector< RenderViewCollection > xrRenderViewCollections
 
std::unique_ptr< AudioPlayer > player
 
timePoint lastFrameTime
 
timeDiff deltaTimeMicroseconds {0}
 
const timeDiff maxTimeStep = std::chrono::milliseconds((long)1000)
 
double time = 0
 

Friends

class NetworkManager
 

Member Function Documentation

◆ AddReplaceWorld()

void App::AddReplaceWorld ( Ref< World >  oldWorld,
Ref< World >  newWorld 
)

Replace a loaded world with a different world, transferring render state if necessary

Parameters
oldWorldthe world to replace
newWorldthe world to replace with. Cannot be already loaded.

◆ AddWorld()

void App::AddWorld ( Ref< World >  world)

Add a world to be ticked

Parameters
worldthe world to tick

◆ CurrentTPS()

float App::CurrentTPS ( )
Returns
the current application tick rate

◆ DispatchMainThread()

template<typename T >
constexpr void RavEngine::App::DispatchMainThread ( const T &  f)
inlineconstexpr
 Dispatch a task to be executed on the main thread.
 @param f the block to execute
 @note To pass parameters, do not reference! Instead, you must explicitly copy the values you want to pass:
 @code

int x = 5; int y = 6; RavEngine::GetApp()->DispatchMainThread([=]{ std::cout << x << y << std::endl; });

◆ GetCurrentTime()

double RavEngine::App::GetCurrentTime ( )
inline
Returns
the current time, measured in seconds since the application launched

◆ OnDropAudioWorklets()

void App::OnDropAudioWorklets ( uint32_t  ndropped)
virtual

Override to be notified if too much audio work was submitted. The default implementation logs a warning.

◆ OnFatal()

virtual void RavEngine::App::OnFatal ( const std::string_view  msg)
inlinevirtual

Override this method to provide a custom fatal handler

◆ OnShutdown()

virtual int RavEngine::App::OnShutdown ( )
inlineprotectedvirtual

Invoked before destructor when the application is expected to shut down. You can return exit codes from here.

◆ OnStartup()

virtual void RavEngine::App::OnStartup ( int  argc,
char **  argv 
)
inlineprotectedvirtual

The startup hook.

Parameters
argcthe number of command line arguments
argvthe command line arguments

◆ Quit()

void App::Quit ( )

Signal to gracefully shut down the application

◆ RemoveAllWorlds()

void App::RemoveAllWorlds ( )

Unload all worlds

◆ RemoveWorld()

void App::RemoveWorld ( Ref< World >  world)

Remove a world from the tick list

Parameters
worldthe world to tick

◆ run()

int App::run ( int  argc,
char **  argv 
)

Invoked automatically. Passes command line arguments.

◆ SetRenderedWorld()

void App::SetRenderedWorld ( Ref< World >  newWorld)

Set the current world to tick automatically

Parameters
newWorldthe new world

◆ SetWindowTitle()

void App::SetWindowTitle ( const char *  title)

Set the window titlebar text

Parameters
titlethe text for the titlebar
Note
Do not call this every frame. To update periodically with data such as frame rates, use a scheduled system.

Member Data Documentation

◆ executor

tf::Executor RavEngine::App::executor
Initial value:
{
std::max<size_t>(std::thread::hardware_concurrency() - 2, 2)
}

The documentation for this class was generated from the following files: