OpenEnroth 2a41f3e
|
#include <EngineDeterministicComponent.h>
Public Member Functions | |
EngineDeterministicComponent () | |
virtual | ~EngineDeterministicComponent () |
void | restart (int frameTimeMs, RandomEngineType rngType) |
void | finish () |
bool | isActive () const |
Private Member Functions | |
virtual int64_t | tickCount () const override |
virtual void | swapBuffers () override |
virtual void | removeNotify () override |
![]() | |
ProxyPlatform (Platform *base=nullptr) | |
virtual | ~ProxyPlatform ()=default |
virtual std::unique_ptr< PlatformWindow > | createWindow () override |
virtual std::unique_ptr< PlatformEventLoop > | createEventLoop () override |
virtual std::vector< PlatformGamepad * > | gamepads () override |
virtual void | setCursorShown (bool cursorShown) override |
virtual bool | isCursorShown () const override |
virtual std::vector< Recti > | displayGeometries () const override |
virtual void | showMessageBox (const std::string &title, const std::string &message) const override |
virtual int64_t | tickCount () const override |
![]() | |
ProxyBase (Platform *base) | |
Platform * | base () const |
void | setBase (Platform *base) |
Platform * | nonNullBase () const |
![]() | |
virtual | ~Platform ()=default |
virtual std::unique_ptr< PlatformWindow > | createWindow ()=0 |
virtual std::unique_ptr< PlatformEventLoop > | createEventLoop ()=0 |
virtual std::vector< PlatformGamepad * > | gamepads ()=0 |
virtual void | setCursorShown (bool cursorShown)=0 |
virtual bool | isCursorShown () const =0 |
virtual std::vector< Recti > | displayGeometries () const =0 |
virtual void | showMessageBox (const std::string &title, const std::string &message) const =0 |
virtual int64_t | tickCount () const =0 |
![]() | |
ProxyOpenGLContext (PlatformOpenGLContext *base=nullptr) | |
virtual | ~ProxyOpenGLContext ()=default |
virtual bool | bind () override |
virtual bool | unbind () override |
virtual void * | nativeHandle () override |
virtual void | swapBuffers () override |
virtual void * | getProcAddress (const char *name) override |
![]() | |
ProxyBase (PlatformOpenGLContext *base) | |
PlatformOpenGLContext * | base () const |
void | setBase (PlatformOpenGLContext *base) |
PlatformOpenGLContext * | nonNullBase () const |
![]() | |
virtual | ~PlatformOpenGLContext ()=default |
virtual bool | bind ()=0 |
virtual bool | unbind ()=0 |
virtual void * | nativeHandle ()=0 |
virtual void | swapBuffers ()=0 |
virtual void * | getProcAddress (const char *name)=0 |
![]() | |
~PlatformApplicationAware ()=default | |
PlatformApplication * | application () const |
template<class T > | |
T * | component () const |
virtual void | installNotify () |
virtual void | removeNotify () |
Private Attributes | |
bool | _active = false |
int64_t | _tickCount = 0 |
int | _frameTimeMs = 0 |
RandomEngineType | _oldRandomEngineType = RANDOM_ENGINE_MERSENNE_TWISTER |
Friends | |
class | PlatformIntrospection |
Additional Inherited Members | |
![]() | |
static std::unique_ptr< Platform > | createStandardPlatform () |
This component can be used to make the engine more deterministic. It replaces the system timer with a fake one that advances by a fixed number of milliseconds each frame, and also resets the global random number generator.
Note that this component is intentionally very dumb. All the methods just do exactly what you would expect right away, so where you're calling them from becomes very important. E.g. calling restart
from an event handler would probably make little sense.
|
default |
|
virtualdefault |
void EngineDeterministicComponent::finish | ( | ) |
Leaves deterministic mode if currently is in it, does nothing otherwise.
|
inline |
|
overrideprivatevirtual |
Called before removal from a PlatformApplication
. application()
will return non-null inside this function.
Reimplemented from PlatformApplicationAware.
void EngineDeterministicComponent::restart | ( | int | frameTimeMs, |
RandomEngineType | rngType | ||
) |
Starts a new deterministic segment, resetting all state - rolls the tick count back to zero, and resets grng
.
Why we're passing frame time in milliseconds here and not setting the target fps directly? For example, it is possible to target 60fps, but since the platform API is in milliseconds, this will result in staggered frame times, with every 1st and 2nd frame taking 17ms, and every 3rd one taking 16ms. This might result in some non-determinism down the line. Unlikely to really affect anything, but we'd rather not find out.
frameTimeMs | Frame time to use inside the segment, in milliseconds. |
rngType | Random engine type to use inside the segment. |
|
overrideprivatevirtual |
Reimplemented from ProxyOpenGLContext.
|
overrideprivatevirtual |
Reimplemented from ProxyPlatform.
|
friend |
|
private |
|
private |
|
private |
|
private |