#include <app.h>
Public Member Functions | |
BaseApp (nap::Core &core) | |
virtual | ~BaseApp ()=default |
BaseApp (BaseApp &)=delete | |
BaseApp & | operator= (const BaseApp &)=delete |
BaseApp (BaseApp &&)=delete | |
BaseApp & | operator= (BaseApp &&)=delete |
virtual bool | init (utility::ErrorState &error) |
virtual void | update (double deltaTime) |
virtual void | render () |
virtual bool | shutdownRequested () |
virtual int | shutdown () |
void | quit () |
const nap::Core & | getCore () const |
nap::Core & | getCore () |
bool | shouldQuit () const |
void | capFramerate (bool value) |
void | setFramerate (float framerate) |
float | getRequestedFramerate () const |
float | getActualFramerate () const |
bool | framerateCapped () const |
Acts as a blueprint for all NAP applications. This class does not receive any input events. Every application holds a reference to a Core object. The init, update, render and shutdown functions are called from within the main loop by the AppRunner.
|
virtualdefault |
void capFramerate | ( | bool | value | ) |
Turns limiting the execution speed of the application on / off. This causes the application to sleep in between calls when execution speed exceeds the set framerate. The final execution speed may vary from platform to platform, based on the accuracy of the timers, but will always be less than the given framerate.
value | if the framerate is capped |
bool framerateCapped | ( | ) | const |
Returns if the execution speed of the application is limited.
float getActualFramerate | ( | ) | const |
Returns the actual (average) execution speed of the application, in frames per second, as measured by core.
float getRequestedFramerate | ( | ) | const |
Returns the requested framerate. This is not the same as the actual framerate. Use Core::getFramerate() to get the actual framerate.
|
virtual |
Initialize your application. Occurs after all the modules have been loaded and services have been initialized. If this call is unsuccessful the application will not continue execution
error | contains the error when initialization fails |
void quit | ( | ) |
Call this from your app to terminate the application and exit the main loop.
|
virtual |
Render your application. This is called after update at the end of the loop
void setFramerate | ( | float | framerate | ) |
Limit execution speed of the application to the given framerate. This causes the application to sleep in between calls when execution speed exceeds the set framerate. The final execution speed may vary from platform to platform, based on the accuracy of the timers, but will always be less than the given framerate. The requested framerate has no effect when the framerate is not capped.
framerate | the requested application framerate. |
bool shouldQuit | ( | ) | const |
|
virtual |
Called when the app is shutting down after quit() has been called Use this to clear application specific data. This is called before all the services are closed and the app exits return the application exit code, 0 (success) by default
|
virtual |
Called by the event handler when it receives an external event to quit the running application By default this calls quit() with the return value of this call, which causes the application to stop running You can override it to ignore the event or perform specific logic (such as saving a file) before the app is shutdown()
|
virtual |
Update your application. This is called after calling update for all registered services but before render
deltaTime | the time in seconds between calls |