Support Forum G3D Web Page |
Application framework for HMD Virtual Reality programs on HTC Vive, Oculus Rift, and Oculus DK2. More...
Inherits G3D::GApp.
Public Types | |
enum | { REAL_TIME = -100, MATCH_REAL_TIME_TARGET = -200 } |
For use as the simulationStepDuration argument of setFrameDuration. More... | |
enum | Action { ACTION_NONE, ACTION_QUIT, ACTION_SHOW_CONSOLE } |
Public Member Functions | |
VRApp (const GApp::Settings &settings=VRApp::Settings()) | |
The window will be forced to non-resizable. More... | |
virtual | ~VRApp () |
virtual const shared_ptr< Camera > & | activeCamera () const |
The currently active camera for the primary view. More... | |
const shared_ptr< Entity > & | activeListener () const |
May be nullptr. More... | |
virtual void | addWidget (const shared_ptr< Widget > &module, bool setFocus=true) |
Installs a module. More... | |
shared_ptr< Manipulator > | cameraManipulator () const |
virtual const shared_ptr< Camera > & | debugCamera () const |
Exposes the debugging camera. More... | |
virtual void | drawDebugShapes () |
Draw everything in debugShapeArray. More... | |
virtual void | drawMessage (const String &message) |
Draw a simple, short message in the center of the screen and swap the buffers. More... | |
void | drawTitle (const String &title, const String &subtitle, const Any &any, const Color3 &fontColor, const Color4 &backColor) |
Draws a title card. More... | |
RealTime | frameDuration () const |
1.0 / desired frame rate More... | |
const GazeTracker::Gaze & | gazeForEye (int eye) const |
const shared_ptr< GazeTracker > & | gazeTracker () const |
const Stopwatch & | graphicsWatch () const |
virtual CFrame | headFrame () const |
The reference fram of the "XR Head" entity if it exists, otherwise the activeCamera frame. More... | |
void | initializeOpenGL (RenderDevice *rd, OSWindow *window, bool createWindowIfNull, const Settings &settings) |
Called from GApp constructor to initialize OpenGL and openGL-dependent state. More... | |
virtual void | loadScene (const String &sceneName) |
Load a new scene. More... | |
const Stopwatch & | logicWatch () const |
bool | lowerFrameRateInBackground () const |
const Stopwatch & | networkWatch () const |
virtual void | onAfterLoadScene (const Any &any, const String &sceneName) override |
Invoked by loadScene() after the scene has been loaded. More... | |
virtual void | onAfterSimulation (RealTime rdt, SimTime sdt, SimTime idt) override |
Invoked after onSimulation is run on the installed GModules and GApp. More... | |
virtual void | onBeforeSimulation (RealTime &rdt, SimTime &sdt, SimTime &idt) override |
Invoked before onSimulation is run on the installed GModules and GApp. More... | |
virtual void | onCleanup () override |
Unload/deallocate your data here. More... | |
virtual bool | onEvent (const GEvent &event) override |
Support for toggling the HUD using the TAB key. More... | |
virtual void | onGraphics (RenderDevice *rd, Array< shared_ptr< Surface > > &surface, Array< shared_ptr< Surface2D > > &surface2D) override |
Set up a double-eye call for onGraphics3D. More... | |
virtual void | onInit () override |
Load your data here. More... | |
RealTime | previousRealTimeStep () const |
Actual wall-clock time elapsed between the previous two frames. More... | |
SimTime | previousSimTimeStep () const |
A non-negative number that is the amount that time is was advanced by in the previous frame. More... | |
RealTime | realTime () const |
Accumulated wall-clock time since init was called on this applet. More... | |
RealTime | realTimeTargetDuration () const |
1.0 / desired frame rate More... | |
void | removeAllDebugShapes () |
Clears all debug shapes, regardless of their pending display time. More... | |
void | removeDebugShape (DebugID id) |
Clears just this debug shape (if it exists), regardless of its pending display time. More... | |
virtual void | removeWidget (const shared_ptr< Widget > &module) |
The actual removal of the module may be delayed until the next frame. More... | |
const shared_ptr< Renderer > & | renderer () |
int | run () |
Call this to run the app. More... | |
virtual void | saveScene () |
Save the current scene over the one on disk. More... | |
const shared_ptr< Scene > & | scene () const |
virtual const SceneVisualizationSettings & | sceneVisualizationSettings () const |
ScreenCapture * | screenCapture () const |
virtual void | setActiveCamera (const shared_ptr< Camera > &camera) override |
The default camera is specified by the scene. More... | |
virtual void | setActiveListener (const shared_ptr< Entity > &listener) |
The default listener is the activeCamera object. More... | |
void | setCameraManipulator (const shared_ptr< Manipulator > &man) |
The manipulator that positions the debugCamera() every frame. More... | |
virtual void | setExitCode (int code=0) |
Invoke to true to end the program at the end of the next event loop. More... | |
virtual void | setFrameDuration (RealTime realTimeTargetDuration, SimTime simulationStepDuration=MATCH_REAL_TIME_TARGET) |
virtual void | setLowerFrameRateInBackground (bool s) |
If true, the wallClockTargetDuration from setFrameDuration() is ignored when the OSWindow does not have focus and the program switches to running 4fps to avoid slowing down the foreground application. More... | |
virtual void | setRealTime (RealTime r) |
virtual void | setSimTime (SimTime s) |
virtual void | setSimulationTimeScale (float s) |
Set the rate at which simulation time actually advances compared to the rate specified by setFrameDuration. More... | |
const Settings & | settings () const |
shared_ptr< GuiWindow > | show (const shared_ptr< Texture > &t, const String &windowCaption="") |
Displays the texture in a new GuiWindow. More... | |
shared_ptr< GuiWindow > | show (const shared_ptr< PixelTransferBuffer > &t, const String &windowCaption="") |
shared_ptr< GuiWindow > | show (const shared_ptr< Image > &t, const String &windowCaption="") |
shared_ptr< TextureBrowserWindow > | showInTextureBrowser (const String &textureName, Rect2D rect=Rect2D::empty()) |
Shows a texture by name. More... | |
shared_ptr< TextureBrowserWindow > | showInTextureBrowser (const shared_ptr< Texture > &texture, Rect2D rect=Rect2D::empty()) |
SimTime | simStepDuration () const |
May also be REAL_TIME or MATCH_REAL_TIME_TARGET. More... | |
SimTime | simTime () const |
In-simulation time since init was called on this applet. More... | |
float | simulationTimeScale () const |
const Stopwatch & | simulationWatch () const |
virtual void | swapBuffers () override |
Intentionally empty so that subclasses don't accidentally swap buffers. More... | |
shared_ptr< Texture > | textureByName (const String &name) const |
Returns a texture by its name, or nullptr if not found. More... | |
template<class SceneSubclass = Scene> | |
shared_ptr< SceneSubclass > | typedScene () const |
const Stopwatch & | userInputWatch () const |
void | vscreenPrintf (const char *fmt, va_list argPtr) |
const Stopwatch & | waitWatch () const |
OSWindow * | window () const |
Static Public Member Functions | |
static GApp * | current () |
Returns a pointer to the current GApp. More... | |
static void | setCurrent (GApp *gApp) |
Sets the current GApp; the current GApp is used for debug drawing. More... | |
Public Attributes | |
bool | catchCommonExceptions |
When true, there is an assertion failure if an exception is thrown. More... | |
GConsoleRef | console |
Command console. More... | |
String | dataDir |
Initialized to GApp::Settings::dataDir, or if that is "<AUTO>", to FilePath::parent(System::currentProgramFilename()). More... | |
std::vector< String > | dataDirs |
Initialized to empty. More... | |
bool | dataDirsAddedToScene = false |
shared_ptr< GFont > | debugFont |
nullptr if not loaded More... | |
Array< DebugLabel > | debugLabelArray |
Labels to be rendered each frame, updated at the same times as debugShapeArray. More... | |
GuiPane * | debugPane |
debugWindow->pane() More... | |
Array< DebugShape > | debugShapeArray |
Shapes to be rendered each frame. More... | |
shared_ptr< GuiWindow > | debugWindow |
Add your own debugging controls to this window. More... | |
shared_ptr< DeveloperWindow > | developerWindow |
The window that displays buttons for debugging. More... | |
Action | escapeKeyAction |
When true an GKey::ESCAPE keydown event quits the program. More... | |
GazeTracker::Gaze * | m_gaze |
Gaze vector for the current eye, relative to the activeCamera(). More... | |
GazeTracker::Gaze | m_gazeArray [2] |
Gaze for each eye for the current frame. More... | |
shared_ptr< GazeTracker > | m_gazeTracker |
Defaults to a cyclops EmulatedGazeTracker. More... | |
DebugID | m_lastDebugID |
Last DebugShape::id issued. More... | |
bool | manageUserInput |
When true, the G3D::UserInput->beginEvents/endEvents processing is handled for you by calling processGEventQueue() before G3D::GApp::onUserInput is called. More... | |
RenderDevice * | renderDevice |
bool | showDebugText |
When true, screenPrintf prints to the screen. More... | |
bool | showRenderingStats |
When true, debugTextWidget prints the frame rate and other data to the screen. More... | |
UserInput * | userInput |
Protected Types | |
typedef GApp | super |
Intended for subclasses to redefine to themselves. More... | |
Protected Member Functions | |
virtual void | addAvatar () |
Invoked by onAfterLoadScene to optionally create avatar parts unless the scene specifies otherwise. More... | |
void | beginRun () |
Initializes state at the beginning of onRun, including calling onCleanup. More... | |
void | createDeveloperHUD () |
Call from onInit to create the developer HUD. More... | |
void | decreaseEffects () |
Called by maybeAdjustEffects when the frame rate is too low. More... | |
void | endRun () |
Cleans up at the end of onRun, including calling onCleanup. More... | |
virtual void | extendGBufferSpecification (GBuffer::Specification &spec) |
Ensures any GBuffer using. More... | |
void | maybeAdjustEffects () |
If frame rate is being consistently missed, reduce the effects on activeCamera() More... | |
CFrame | maybeRemovePitchAndRoll (const CFrame &source) const |
if m_cameraManipulator is a FirstPersonManipulator and m_trackingOverridesPitch is true, then zero out the pitch and roll in source More... | |
virtual void | onAfterEvents () |
virtual void | onAI () |
Update any state you need to here. More... | |
virtual void | onConsoleCommand (const String &cmd) |
Invoked when a user presses enter in the in-game console. More... | |
virtual void | oneFrame () |
A single frame of rendering, simulation, AI, events, networking, etc. More... | |
virtual void | onGraphics2D (RenderDevice *rd, Array< shared_ptr< Surface2D > > &surface2D) |
Called from the default onGraphics. More... | |
virtual void | onGraphics3D (RenderDevice *rd, Array< shared_ptr< Surface > > &surface) |
Called from the default onGraphics. More... | |
virtual void | onNetwork () |
For a networked app, override this to implement your network message polling. More... | |
virtual void | onPose (Array< shared_ptr< Surface > > &posed3D, Array< shared_ptr< Surface2D > > &posed2D) |
Called before onGraphics. More... | |
virtual void | onPostProcessHDR3DEffects (RenderDevice *rd) |
Invoked by the default onGraphics3D to perform depth of field and motion blur post-processgiing on the m_framebuffer at high dynamic range. More... | |
void | onRun () |
Helper for run() that actually starts the program loop. More... | |
virtual void | onSimulation (RealTime rdt, SimTime sdt, SimTime idt) |
Override this with your simulation code. More... | |
virtual void | onUserInput (class UserInput *userInput) |
Routine for processing user input from the previous frame. More... | |
virtual void | onWait (RealTime waitTime) |
Task to be used for frame rate limiting. More... | |
virtual void | processGEventQueue () |
Processes all pending events on the OSWindow queue into the userInput. More... | |
void | processTeleportation (RealTime rdt) |
virtual void | renderCubeMap (RenderDevice *rd, Array< shared_ptr< Texture > > &output, const shared_ptr< Camera > &camera, const shared_ptr< Texture > &depthMap, int resolution=1024) |
Helper for generating cube maps. More... | |
virtual void | resize (int w, int h) |
Change the size of the underlying Film. More... | |
virtual void | sampleGazeTrackerData () |
virtual void | setScene (const shared_ptr< Scene > &s) |
void | setSubmitToDisplayMode (SubmitToDisplayMode m) |
Defaults to SubmitMode::MAXIMIZE_THROUGHPUT. More... | |
SubmitToDisplayMode | submitToDisplayMode () const |
virtual void | vrSubmitToDisplay () |
VR equivalent of swapBuffers() for the HMD. More... | |
Static Protected Member Functions | |
static void | staticConsoleCallback (const String &command, void *me) |
Protected Attributes | |
Array< String > | debugText |
Strings that have been printed with screenPrintf. More... | |
shared_ptr< Camera > | m_activeCamera |
The currently selected camera. More... | |
shared_ptr< MarkerEntity > | m_activeCameraMarker |
Follows the activeCamera. More... | |
shared_ptr< Entity > | m_activeListener |
shared_ptr< class AmbientOcclusion > | m_ambientOcclusion |
Default/current AO object for the primary view, allocated in GApp::GApp. More... | |
shared_ptr< AmbientOcclusion > | m_ambientOcclusionArray [MAX_VIEWS] |
Per-eye. More... | |
shared_ptr< Manipulator > | m_cameraManipulator |
Used to find the frame for defaultCamera. More... | |
int | m_currentEyeIndex |
Set by onGraphics for each onGraphics3D call in VRApp. More... | |
shared_ptr< Texture > | m_cursorPointerTexture |
shared_ptr< Camera > | m_debugCamera |
A camera that is driven by the debugController. More... | |
shared_ptr< FirstPersonManipulator > | m_debugController |
Allows first person (Quake game-style) control using the arrow keys or W,A,S,D and the mouse. More... | |
Color4 | m_debugTextColor |
std::mutex | m_debugTextMutex |
Color4 | m_debugTextOutlineColor |
shared_ptr< DebugTextWidget > | m_debugTextWidget |
shared_ptr< DepthOfField > | m_depthOfField |
shared_ptr< Framebuffer > | m_depthPeelFramebuffer |
shared_ptr< Framebuffer > | m_deviceFramebuffer |
The current device [LDR] framebuffer. More... | |
bool | m_endProgram |
int | m_exitCode |
shared_ptr< Film > | m_film |
Allocated if GApp::Settings::FilmSettings::enabled was true when the constructor executed. More... | |
bool | m_forceDiskFramebuffer = true |
If true, remove the outer part of the view that will not appear in VR. More... | |
shared_ptr< Framebuffer > | m_framebuffer |
The framebuffer that will be used by the default onGraphics3D. More... | |
shared_ptr< GBuffer > | m_gbuffer |
Bound to the current GBuffer, which is m_osWindowGBuffer by default. More... | |
GBuffer::Specification | m_gbufferSpecification |
Stopwatch | m_graphicsWatch |
bool | m_highQualityWarping |
Automatically turned on when the scene is loaded, disabled only if frame rate can't be maintained. More... | |
shared_ptr< Framebuffer > | m_hmdDeviceFramebuffer [MAX_VIEWS] |
LDR faux-"hardware framebuffer" for the HMD, comparable to GApp::m_osWindowDeviceFramebuffer. More... | |
shared_ptr< Film > | m_hmdFilm [2] |
Per eye Film instance for VR. More... | |
shared_ptr< GBuffer > | m_hmdGBuffer [2] |
The active m_gbuffer is switched between these per eye. More... | |
shared_ptr< Framebuffer > | m_hmdHDRFramebuffer [MAX_VIEWS] |
The HDR framebuffer used by G3D::Film for the HMD. More... | |
Color4 | m_hudBackgroundColor |
Color of the HUD background, which reveals the boundaries of the virtual display. More... | |
float | m_hudEnabled |
If true, onGraphics2D is captured and displayed in the HMD. More... | |
CFrame | m_hudFrame |
Position at which onGraphics2D renders on the virtual HUD layer if m_hudEnabled == true. More... | |
float | m_hudWidth |
Width in meters of the HUD layer used to display onGraphics2D content in the HMD. More... | |
RealTime | m_lastFrameOverWait |
Used to track how much onWait overshot its desired target during the previous frame. More... | |
RealTime | m_lastTime |
RealTime | m_lastWaitTime |
Used by onWait for elapsed time. More... | |
Stopwatch | m_logicWatch |
bool | m_lowerFrameRateInBackground |
If true, the wallClockTargetDuration from setFrameDuration() is ignored when the OSWindow does not have focus and the program switches to running 4fps to avoid slowing down the foreground application. More... | |
bool | m_maintainHeightOverGround = true |
If true, teleport the XR Tracked Volume as needed to maintain constant height above ground (as determined by ray casting). More... | |
shared_ptr< MotionBlur > | m_motionBlur |
Stopwatch | m_networkWatch |
RealTime | m_now |
Used by onSimulation for elapsed time. More... | |
int | m_numSlowFrames |
The number of frames during which the renderer failed to reach the desired frame rate. More... | |
shared_ptr< Framebuffer > | m_osWindowDeviceFramebuffer |
The (probably low dynamic range, one sample per pixel) OpenGL hardware framebuffer for the window(). More... | |
shared_ptr< GBuffer > | m_osWindowGBuffer |
GBuffer used for the OSWindow. More... | |
shared_ptr< Framebuffer > | m_osWindowHDRFramebuffer |
Framebuffer used for rendering the 3D portion of the scene. More... | |
Array< shared_ptr< Surface2D > > | m_posed2D |
Array< shared_ptr< Surface > > | m_posed3D |
Stopwatch | m_poseWatch |
float | m_previousRealTimeStep |
float | m_previousSimTimeStep |
RealTime | m_realTime |
shared_ptr< Renderer > | m_renderer |
Used by the default onGraphics3D to render Surfaces. More... | |
int | m_renderPeriod |
onPose(), onGraphics(), and onWait() execute once every m_renderPeriod simulation frames. More... | |
Settings | m_settings |
The original settings. More... | |
SimTime | m_simTime |
float | m_simTimeScale |
float | m_simTimeStep |
SimTime seconds per frame,. More... | |
Stopwatch | m_simulationWatch |
Stopwatch | m_userInputWatch |
SubmitToDisplayMode | m_vrSubmitToDisplayMode |
Stopwatch | m_waitWatch |
float | m_wallClockTargetDuration |
Seconds per frame target for the entire system. More... | |
shared_ptr< WidgetManager > | m_widgetManager |
shared_ptr< XR > | m_xrSystem |
The low-level XR API. More... | |
shared_ptr< XRWidget > | m_xrWidget |
Static Protected Attributes | |
static const int | MAX_SLOW_FRAMES = 20 |
static const unsigned int | MAX_VIEWS = 4 |
Maximum number of views ("eyes") for HMD 0. More... | |
static GApp * | s_currentGApp |
Pointer to the current GApp. More... | |
Application framework for HMD Virtual Reality programs on HTC Vive, Oculus Rift, and Oculus DK2.
Use the tab key to toggle seeing the GUI in the HMD.
For many programs, simply changing from inheriting your App from GApp to VRApp will immediately add HMD support. You must have the OpenVR Runtime (AKA SteamVR) installed to use VRApp. OpenVR is a free download as part of (Steam)[https://steamcdn-a.akamaihd.net/client/installer/SteamSetup.exe], which is also free download for multiple platforms.
You do not need to install the Oculus, SteamVR, or OpenVR SDKs–G3D includes the files that you need.
There are several MarkerEntity and reference frames at play for VR in order to attempt to model the degrees of freedom for a tracked HMD while still minimizing the amount of code needed to make a non-VR GApp subclass run as a VRGApp subclass. This API is in a very early state and subject to continous change.
The reference frames are:
Beware that this has some important implications:
Supports the following extra fields on G3D::Scene in a data file for automatically adding G3D::VisibleEntity instances with appropriate geometry that track the relevant MarkerEntity created by XRWidget:
|
protected |
Intended for subclasses to redefine to themselves.
This allows application subclasses to invoke super::onInit
, etc., and easily change their base class without rewriting all methods.
|
inherited |
For use as the simulationStepDuration argument of setFrameDuration.
|
inherited |
G3D::VRApp::VRApp | ( | const GApp::Settings & | settings = VRApp::Settings() | ) |
The window will be forced to non-resizable.
|
virtual |
|
inlinevirtualinherited |
The currently active camera for the primary view.
The special G3D::MarkerEntity named "(Active Camera Marker)" follows whichever camera is currently active. It does not update when the camera is not in the scene.
|
inlineinherited |
May be nullptr.
|
protectedvirtual |
Invoked by onAfterLoadScene to optionally create avatar parts unless the scene specifies otherwise.
|
virtualinherited |
Installs a module.
Actual insertion may be delayed until the next frame.
Referenced by G3D::GApp::setCameraManipulator().
|
protectedinherited |
Initializes state at the beginning of onRun, including calling onCleanup.
|
inlineinherited |
|
protectedinherited |
Call from onInit to create the developer HUD.
|
staticinherited |
|
inlinevirtualinherited |
Exposes the debugging camera.
|
protected |
Called by maybeAdjustEffects when the frame rate is too low.
|
virtualinherited |
Draw everything in debugShapeArray.
Subclasses should call from onGraphics3D() or onGraphics(). This will sort the debugShapeArray from back to front according to the current camera.
|
virtualinherited |
Draw a simple, short message in the center of the screen and swap the buffers.
Useful for loading screens and other slow operations.
|
inherited |
Draws a title card.
|
protectedinherited |
Cleans up at the end of onRun, including calling onCleanup.
|
protectedvirtualinherited |
Ensures any GBuffer using.
spec | has all of the fields necessary to render the effects on this GApp. By default, extends the specification to handle the current AmbientOcclusionSettings, DepthOfFieldSettings, MotionBlurSettings, and FilmSettings. |
Called from GApp::onGraphics3D.
|
inlineinherited |
1.0 / desired frame rate
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
virtualinherited |
The reference fram of the "XR Head" entity if it exists, otherwise the activeCamera frame.
This allows unifying code across desktop and VR rendering. The VR APIs do not move the activeCamera with the HMD because XRWidget leaves that unmodified to represent the default tracking volume.
|
inherited |
Called from GApp constructor to initialize OpenGL and openGL-dependent state.
Can't be virtual because it is invoked from a constructor, but allows subclasses to perform their own pre-OpenGL steps.
|
virtualinherited |
Load a new scene.
A GApp may invoke this on itself, and the SceneEditorWindow will invoke this automatically when the user presses Reload or chooses a new scene from the GUI.
|
inlineinherited |
|
inlineinherited |
|
protected |
If frame rate is being consistently missed, reduce the effects on activeCamera()
if m_cameraManipulator is a FirstPersonManipulator and m_trackingOverridesPitch is true, then zero out the pitch and roll in source
|
inlineinherited |
|
protectedvirtualinherited |
|
overridevirtual |
Invoked by loadScene() after the scene has been loaded.
This allows the GApp to modify the scene or load custom properties from the any structure.
The scene can be accessed using the scene() method.
Reimplemented from G3D::GApp.
|
protectedvirtualinherited |
Update any state you need to here.
This is a good place for AI code, for example. Called after onNetwork and onUserInput, before onSimulation.
|
overridevirtual |
Invoked before onSimulation is run on the installed GModules and GApp.
This is not used by most programs; it is primarily a hook for those performing extensive physical simulation on the GModules that need a setup and cleanup step.
If you mutate the timestep arguments then those mutated time steps are passed to the onSimulation method. However, the accumulated time will not be affected by the changed timestep.
Reimplemented from G3D::GApp.
|
overridevirtual |
Unload/deallocate your data here.
Unlike the destructor, this catches common exceptions. It is called after the last frame is processed.
Reimplemented from G3D::GApp.
|
protectedvirtualinherited |
Invoked when a user presses enter in the in-game console.
The default implementation ends the program if the command is "exit".
Sample implementation:
void App::onConsoleCommand(const String& str) { // Add console processing here TextInput t(TextInput::FROM_STRING, str); if (t.isValid() && (t.peek().type() == Token::SYMBOL)) { String cmd = toLower(t.readSymbol()); if (cmd == "exit") { setExitCode(0); return; } else if (cmd == "help") { printConsoleHelp(); return; } // Add commands here } console->printf("Unknown command\n"); printConsoleHelp(); } void App::printConsoleHelp() { console->printf("exit - Quit the program\n"); console->printf("help - Display this text\n\n"); console->printf("~/ESC - Open/Close console\n"); console->printf("F2 - Enable first-person camera control\n"); console->printf("F4 - Record video\n"); }
|
protectedvirtualinherited |
A single frame of rendering, simulation, AI, events, networking, etc.
Invokes the onXXX methods and performs timing.
|
overridevirtual |
Support for toggling the HUD using the TAB key.
Reimplemented from G3D::GApp.
|
overridevirtual |
|
protectedvirtualinherited |
Called from the default onGraphics.
|
protectedvirtualinherited |
Called from the default onGraphics.
Override and implement.
The default implementation is a full forward renderer with AO and post processing. See the starter sample project for equivalent code.
|
overridevirtual |
Load your data here.
Unlike the constructor, this catches common exceptions. It is called before the first frame is processed.
Reimplemented from G3D::GApp.
|
protectedvirtualinherited |
For a networked app, override this to implement your network message polling.
|
protectedvirtualinherited |
Called before onGraphics.
Append any models that you want rendered (you can also explicitly pose and render in your onGraphics method). The provided arrays will already contain posed models from any installed Widgets.
|
protectedvirtualinherited |
Invoked by the default onGraphics3D to perform depth of field and motion blur post-processgiing on the m_framebuffer at high dynamic range.
Does not include the tone-mapping (Film::exposeAndRender) HDR to LDR pass.
|
protectedinherited |
|
protectedvirtualinherited |
Override this with your simulation code.
Called from GApp::run.
The default implementation invokes WidgetManager::onSimulation on m_widgetManager, Scene::onSimulation on scene(), and GCamera::onSimulation on GApp::m_debugCamera in that order.
simTime(), idealSimTime() and realTime() are incremented after onSimulation is called, so at the beginning of call the current time is the end of the previous frame.
rdt | Elapsed real-world time since the last call to onSimulation. |
sdt | Elapsed sim-world time since the last call to onSimulation, computed by multiplying the wall-clock time by the simulation time rate. |
idt | Elapsed ideal sim-world time. Use this for perfectly reproducible timing results. Ideal time always advances by the desiredFrameDuration * simTimeRate, no matter how much wall-clock time has elapsed. |
|
protectedvirtualinherited |
Routine for processing user input from the previous frame.
Default implementation does nothing.
|
protectedvirtualinherited |
Task to be used for frame rate limiting.
Overriding onWait is not recommended unless you have significant computation tasks that cannot be executed conveniently on a separate thread.
Frame rate limiting is useful to avoid overloading a maching that is running background tasks and for situations where fixed time steps are needed for simulation and there is no reason to render faster.
Default implementation System::sleep()s on waitTime (which is always non-negative)
|
inlineinherited |
Actual wall-clock time elapsed between the previous two frames.
|
inlineinherited |
A non-negative number that is the amount that time is was advanced by in the previous frame.
Never an enum value. For the first frame, this is the amount that time will be advanced by if rendering runs at speed.
|
protectedvirtualinherited |
Processes all pending events on the OSWindow queue into the userInput.
This is automatically called once per frame. You can manually call it more frequently to get higher resolution mouse tracking or to prevent the OS from locking up (and potentially crashing) while in a lengthy onGraphics call.
|
protected |
|
inlineinherited |
Accumulated wall-clock time since init was called on this applet.
Since this time is accumulated, it may drift from the true wall-clock obtained by System::time().
|
inlineinherited |
|
inherited |
Clears all debug shapes, regardless of their pending display time.
|
inherited |
Clears just this debug shape (if it exists), regardless of its pending display time.
|
virtualinherited |
The actual removal of the module may be delayed until the next frame.
Referenced by G3D::GApp::setCameraManipulator().
|
protectedvirtualinherited |
Helper for generating cube maps.
Invokes GApp::onGraphics3D six times, once for each face of a cube map. This is convenient both for microrendering and for generating cube maps to later use offline.
certain post processing effects are applied to the final image. Motion blur and depth of field are not but AO is if enabled. However AO will causes artifacts on the final image when enabled.
output | If empty or the first element is nullptr, this is set to a series of new reslolution x resolution ImageFormat::RGB16F() textures. Otherwise, the provided elements are used. Textures are assumed to be square. The images are generated in G3D::CubeFace order. |
camera | the camera will have all of its parameters reset before the end of the call. |
depthMap | Optional pre-allocated depth texture to use as the depth map when rendering each face. Will be allocated to match the texture resolution if not provided. The default depth format is ImageFormat::DEPTH24(). |
Example:
|
inlineinherited |
|
protectedvirtualinherited |
Change the size of the underlying Film.
Called by GApp::GApp() and GApp::onEvent(). This is not an event handler. If you want to be notified when your app is resized, override GApp::onEvent to handle the resize event (just don't forget to call GApp::onEvent as well).
The guard band sizes are added to the specified width and height
|
inherited |
Call this to run the app.
|
protectedvirtualinherited |
|
virtualinherited |
Save the current scene over the one on disk.
|
inlineinherited |
|
virtualinherited |
|
inlineinherited |
|
overridevirtual |
The default camera is specified by the scene.
Use the F2 key under the developer HUD to quickly switch to the debug camera. During rendering (e.g., by VRApp) the active camera may be temporarily changed.
If the scene() is not null, also creates a G3D::MarkerEntity named "activeCamera" in the scene that is at the position of this camera.
Reimplemented from G3D::GApp.
|
inlinevirtualinherited |
The default listener is the activeCamera object.
Set to nullptr to disable actively setting the underlying AudioDevice::setListener3DAttributes every frame if you intend to change those explicitly in your app.
The default value is scene()->entity("(Active Camera Marker)")
.
|
inlineinherited |
The manipulator that positions the debugCamera() every frame.
By default, this is set to an instance of G3D::FirstPersonManipulator. This may be set to shared_ptr<Manipulator>()
to disable explicit camera positioning.
Setting a camera manipulator automatically also adds it as a Widget if it is not already present. Overriding the camera manipulator automatically removes the previous manipulator as a Widget.
Example:
|
staticinherited |
|
virtualinherited |
Invoke to true to end the program at the end of the next event loop.
|
inlinevirtualinherited |
realTimeTargetDuration | Target duration between successive frames. If simulating and rendering (and all other onX methods) consume less time than this, then GApp will invoke onWait() to throttle. If the frame takes more time than wallClockTargetDuration, then the system will proceed to the next frame as quickly as it can. |
simulationStepDuration | Amount to increment simulation time by each frame under normal circumstances (this is modified by setSimulationTimeScale) Special values are GApp::REAL_TIME, GApp::MATCH_REAL_TIME_TARGET. |
|
inlinevirtualinherited |
If true, the wallClockTargetDuration from setFrameDuration() is ignored when the OSWindow does not have focus and the program switches to running 4fps to avoid slowing down the foreground application.
|
virtualinherited |
|
inlineprotectedvirtualinherited |
|
virtualinherited |
|
inlinevirtualinherited |
|
inlineprotectedinherited |
Defaults to SubmitMode::MAXIMIZE_THROUGHPUT.
SubmitToDisplayMode::EXPLICIT requires an explicit call to swapBuffers()–GApp does not perform swapping in this case.
SubmitToDisplayMode::MAXIMIZE_THROUGHPUT swaps in the middle of the next frame, as soon as it needs to write to the hardware framebuffer to maximize throughput (framerate). This allows CPU physics, network, audio, AI, scene traversal, etc. to overlap GPU rendering, and even allows GPU work submission for offscreen buffers for the next frame to overlap GPU execution of the current frame.
SubmitToDisplayMode::BALANCE swaps at the beginning of the next frame to balance throughput and latency. This allows CPU physics, network, audio, AI, scene traversal, etc. to overlap GPU rendering.
SubmitToDisplayMode::MINIMIZE_LATENCY swaps at the end of the current frame to minimize latency. This blocks the CPU on the GPU until the currently-submitted work is complete.
|
inlineinherited |
|
inherited |
Displays the texture in a new GuiWindow.
|
inherited |
|
inherited |
|
inherited |
Shows a texture by name.
Convenient for creating debugging views of textures that are not exposed by other objects. Returns nullptr if the texture is not currently in memory.
|
inherited |
|
inlineinherited |
May also be REAL_TIME or MATCH_REAL_TIME_TARGET.
|
inlineinherited |
In-simulation time since init was called on this applet.
Takes into account simTimeSpeed. Automatically incremented after ooSimulation.
|
inlineinherited |
|
inlineinherited |
|
staticprotectedinherited |
|
inlineprotectedinherited |
|
overridevirtual |
Intentionally empty so that subclasses don't accidentally swap buffers.
Simplifies upgrading existing apps to VRApps
Reimplemented from G3D::GApp.
Returns a texture by its name, or nullptr if not found.
Useful for bypassing language protection mechanisms when creating debugging GUIs
|
inlineinherited |
|
inlineinherited |
|
protectedvirtual |
VR equivalent of swapBuffers() for the HMD.
|
inherited |
|
inlineinherited |
|
inlineinherited |
|
inherited |
When true, there is an assertion failure if an exception is thrown.
Default is true.
|
inherited |
Command console.
|
inherited |
Initialized to GApp::Settings::dataDir, or if that is "<AUTO>", to FilePath::parent(System::currentProgramFilename()).
To make your program distributable, override the default and copy all data files you need to a local directory. Recommended setting is "data/" or "./", depending on where you put your data relative to the executable.
Your data directory must contain the default debugging font, "console-small.fnt", unless you change it.
|
inherited |
Initialized to empty.
Used for additional data directories in projects that have data in multiple folders in the filesystem hierarchy. Use std::vector for convenience when calling System::setAppDataDirs(const std::vector<String>& dataDirs).
|
inherited |
|
inherited |
nullptr if not loaded
|
inherited |
Labels to be rendered each frame, updated at the same times as debugShapeArray.
|
inherited |
debugWindow->pane()
|
inherited |
Shapes to be rendered each frame.
Added to by G3D::debugDraw. Rendered by drawDebugShapes(); Automatically cleared once per frame.
Strings that have been printed with screenPrintf.
Protected by m_debugTextMutex.
|
inherited |
Add your own debugging controls to this window.
|
inherited |
The window that displays buttons for debugging.
If GApp::Settings::useDeveloperTools is true this will be created and added as a Widget on the GApp. Otherwise this will be nullptr.
|
inherited |
When true an GKey::ESCAPE keydown event quits the program.
(default is true)
|
protectedinherited |
The currently selected camera.
Referenced by G3D::GApp::activeCamera().
|
protectedinherited |
Follows the activeCamera.
In the Scene.
|
protectedinherited |
Referenced by G3D::GApp::activeListener(), and G3D::GApp::setActiveListener().
|
protectedinherited |
Default/current AO object for the primary view, allocated in GApp::GApp.
|
protected |
Per-eye.
|
protectedinherited |
Used to find the frame for defaultCamera.
Referenced by G3D::GApp::cameraManipulator(), and G3D::GApp::setCameraManipulator().
|
protectedinherited |
|
protected |
|
protectedinherited |
A camera that is driven by the debugController.
This is a copy of the default camera from the scene, but is not itself in the scene.
Do not reassign this–the CameraControlWindow is hardcoded to the original one.
Referenced by G3D::GApp::debugCamera().
|
protectedinherited |
Allows first person (Quake game-style) control using the arrow keys or W,A,S,D and the mouse.
To disable, use:
setCameraManipulator(nullptr);
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
Allocated if GApp::Settings::FilmSettings::enabled was true when the constructor executed.
Automatically resized by resize() when the screen size changes.
|
protected |
If true, remove the outer part of the view that will not appear in VR.
If you change this from the default, do so before loadScene or onGraphics is invoked
|
protectedinherited |
The framebuffer that will be used by the default onGraphics3D.
GApp binds this to m_osWindowHDRFramebuffer by default. VRApp binds it to VRApp::m_hmdHDRFramebuffer[VRApp::m_currentEye].
|
inherited |
Gaze vector for the current eye, relative to the activeCamera().
This is a pointer into m_gazeArray
|
inherited |
Gaze for each eye for the current frame.
Referenced by G3D::GApp::gazeForEye().
|
inherited |
Defaults to a cyclops EmulatedGazeTracker.
Set to a binocular EmulatedGazeTracker for a slightly slower but much better binocular simulation (tip: turn on Modle::accelerated ray casts for that), or instantiate a real gaze tracker if you have one.
Referenced by G3D::GApp::gazeTracker().
|
protectedinherited |
Bound to the current GBuffer, which is m_osWindowGBuffer by default.
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::GApp::graphicsWatch().
|
protected |
Automatically turned on when the scene is loaded, disabled only if frame rate can't be maintained.
|
protected |
LDR faux-"hardware framebuffer" for the HMD, comparable to GApp::m_osWindowDeviceFramebuffer.
The m_framebuffer is still bound during the default onGraphics3D and then resolved by Film to the m_hmdDeviceFramebuffer.
|
protected |
Per eye Film instance for VR.
onGraphics switches m_film between them.
|
protected |
The active m_gbuffer is switched between these per eye.
That allows reprojection between them.
|
protected |
The HDR framebuffer used by G3D::Film for the HMD.
Comparable to GApp::monitorFramebuffer.
|
protected |
Color of the HUD background, which reveals the boundaries of the virtual display.
|
protected |
If true, onGraphics2D is captured and displayed in the HMD.
By default, TAB toggles this.
|
protected |
Position at which onGraphics2D renders on the virtual HUD layer if m_hudEnabled == true.
|
protected |
Width in meters of the HUD layer used to display onGraphics2D content in the HMD.
|
inherited |
Last DebugShape::id issued.
|
protectedinherited |
Used to track how much onWait overshot its desired target during the previous frame.
|
protectedinherited |
|
protectedinherited |
Used by onWait for elapsed time.
|
protectedinherited |
Referenced by G3D::GApp::logicWatch().
|
protectedinherited |
If true, the wallClockTargetDuration from setFrameDuration() is ignored when the OSWindow does not have focus and the program switches to running 4fps to avoid slowing down the foreground application.
Referenced by G3D::GApp::lowerFrameRateInBackground(), and G3D::GApp::setLowerFrameRateInBackground().
|
protected |
If true, teleport the XR Tracked Volume as needed to maintain constant height above ground (as determined by ray casting).
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::GApp::networkWatch().
|
protectedinherited |
Used by onSimulation for elapsed time.
|
protected |
The number of frames during which the renderer failed to reach the desired frame rate.
When this count hits MAX_SLOW_FRAMES, some post effects are disabled and m_numSlowFrames resets.
|
protectedinherited |
The (probably low dynamic range, one sample per pixel) OpenGL hardware framebuffer for the window().
Initialized in initializeOpenGL().
|
protectedinherited |
|
protectedinherited |
Framebuffer used for rendering the 3D portion of the scene.
Includes a color guard band. This is then resolved to m_osWindowDeviceFramebuffer.
|
protectedinherited |
|
protectedinherited |
Referenced by G3D::GApp::previousRealTimeStep().
|
protectedinherited |
Referenced by G3D::GApp::previousSimTimeStep().
|
protectedinherited |
Referenced by G3D::GApp::realTime().
|
protectedinherited |
Used by the default onGraphics3D to render Surfaces.
Referenced by G3D::GApp::renderer().
|
protectedinherited |
onPose(), onGraphics(), and onWait() execute once every m_renderPeriod simulation frames.
This allows UI/network/simulation to be clocked much faster than rendering to increase responsiveness.
|
protectedinherited |
The original settings.
Referenced by G3D::GApp::settings().
|
protectedinherited |
Referenced by G3D::GApp::simTime().
|
protectedinherited |
Referenced by G3D::GApp::setSimulationTimeScale(), and G3D::GApp::simulationTimeScale().
|
protectedinherited |
SimTime seconds per frame,.
Referenced by G3D::GApp::setFrameDuration(), and G3D::GApp::simStepDuration().
|
protectedinherited |
Referenced by G3D::GApp::simulationWatch().
|
protectedinherited |
Referenced by G3D::GApp::userInputWatch().
|
protected |
|
protectedinherited |
Referenced by G3D::GApp::waitWatch().
|
protectedinherited |
Seconds per frame target for the entire system.
Referenced by G3D::GApp::frameDuration(), G3D::GApp::realTimeTargetDuration(), and G3D::GApp::setFrameDuration().
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
inherited |
When true, the G3D::UserInput->beginEvents/endEvents processing is handled for you by calling processGEventQueue() before G3D::GApp::onUserInput is called.
If you turn this off, you must call processGEventQueue() or provide your own event to userInput processing in onUserInput. (default is true)
|
staticprotected |
|
staticprotected |
Maximum number of views ("eyes") for HMD 0.
|
inherited |
|
staticprotectedinherited |
|
inherited |
When true, screenPrintf prints to the screen.
(default is true)
|
inherited |
When true, debugTextWidget prints the frame rate and other data to the screen.
|
inherited |