Support Forum       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
G3D::VRApp Class Reference

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< ManipulatorcameraManipulator () 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::GazegazeForEye (int eye) const
 
const shared_ptr< GazeTracker > & gazeTracker () const
 
const StopwatchgraphicsWatch () 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 StopwatchlogicWatch () const
 
bool lowerFrameRateInBackground () const
 
const StopwatchnetworkWatch () 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 SceneVisualizationSettingssceneVisualizationSettings () const
 
ScreenCapturescreenCapture () 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 Settingssettings () const
 
shared_ptr< GuiWindowshow (const shared_ptr< Texture > &t, const String &windowCaption="")
 Displays the texture in a new GuiWindow. More...
 
shared_ptr< GuiWindowshow (const shared_ptr< PixelTransferBuffer > &t, const String &windowCaption="")
 
shared_ptr< GuiWindowshow (const shared_ptr< Image > &t, const String &windowCaption="")
 
shared_ptr< TextureBrowserWindowshowInTextureBrowser (const String &textureName, Rect2D rect=Rect2D::empty())
 Shows a texture by name. More...
 
shared_ptr< TextureBrowserWindowshowInTextureBrowser (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 StopwatchsimulationWatch () const
 
virtual void swapBuffers () override
 Intentionally empty so that subclasses don't accidentally swap buffers. More...
 
shared_ptr< TexturetextureByName (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 StopwatchuserInputWatch () const
 
void vscreenPrintf (const char *fmt, va_list argPtr)
 
const StopwatchwaitWatch () const
 
OSWindowwindow () const
 

Static Public Member Functions

static GAppcurrent ()
 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< StringdataDirs
 Initialized to empty. More...
 
bool dataDirsAddedToScene = false
 
shared_ptr< GFontdebugFont
 nullptr if not loaded More...
 
Array< DebugLabeldebugLabelArray
 Labels to be rendered each frame, updated at the same times as debugShapeArray. More...
 
GuiPanedebugPane
 debugWindow->pane() More...
 
Array< DebugShapedebugShapeArray
 Shapes to be rendered each frame. More...
 
shared_ptr< GuiWindowdebugWindow
 Add your own debugging controls to this window. More...
 
shared_ptr< DeveloperWindowdeveloperWindow
 The window that displays buttons for debugging. More...
 
Action escapeKeyAction
 When true an GKey::ESCAPE keydown event quits the program. More...
 
GazeTracker::Gazem_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< GazeTrackerm_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...
 
RenderDevicerenderDevice
 
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...
 
UserInputuserInput
 

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< StringdebugText
 Strings that have been printed with screenPrintf. More...
 
shared_ptr< Cameram_activeCamera
 The currently selected camera. More...
 
shared_ptr< MarkerEntitym_activeCameraMarker
 Follows the activeCamera. More...
 
shared_ptr< Entitym_activeListener
 
shared_ptr< class AmbientOcclusionm_ambientOcclusion
 Default/current AO object for the primary view, allocated in GApp::GApp. More...
 
shared_ptr< AmbientOcclusionm_ambientOcclusionArray [MAX_VIEWS]
 Per-eye. More...
 
shared_ptr< Manipulatorm_cameraManipulator
 Used to find the frame for defaultCamera. More...
 
int m_currentEyeIndex
 Set by onGraphics for each onGraphics3D call in VRApp. More...
 
shared_ptr< Texturem_cursorPointerTexture
 
shared_ptr< Cameram_debugCamera
 A camera that is driven by the debugController. More...
 
shared_ptr< FirstPersonManipulatorm_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< DebugTextWidgetm_debugTextWidget
 
shared_ptr< DepthOfFieldm_depthOfField
 
shared_ptr< Framebufferm_depthPeelFramebuffer
 
shared_ptr< Framebufferm_deviceFramebuffer
 The current device [LDR] framebuffer. More...
 
bool m_endProgram
 
int m_exitCode
 
shared_ptr< Filmm_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< Framebufferm_framebuffer
 The framebuffer that will be used by the default onGraphics3D. More...
 
shared_ptr< GBufferm_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< Framebufferm_hmdDeviceFramebuffer [MAX_VIEWS]
 LDR faux-"hardware framebuffer" for the HMD, comparable to GApp::m_osWindowDeviceFramebuffer. More...
 
shared_ptr< Filmm_hmdFilm [2]
 Per eye Film instance for VR. More...
 
shared_ptr< GBufferm_hmdGBuffer [2]
 The active m_gbuffer is switched between these per eye. More...
 
shared_ptr< Framebufferm_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< MotionBlurm_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< Framebufferm_osWindowDeviceFramebuffer
 The (probably low dynamic range, one sample per pixel) OpenGL hardware framebuffer for the window(). More...
 
shared_ptr< GBufferm_osWindowGBuffer
 GBuffer used for the OSWindow. More...
 
shared_ptr< Framebufferm_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< Rendererm_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< WidgetManagerm_widgetManager
 
shared_ptr< XRm_xrSystem
 The low-level XR API. More...
 
shared_ptr< XRWidgetm_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 GApps_currentGApp
 Pointer to the current GApp. More...
 

Detailed Description

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:

vr = {
avatar = {
addHandEntity = true;
addControllerEntity = true;
addTorsoEntity = true;
}
}
See also
XR, XRWidget

Member Typedef Documentation

◆ super

typedef GApp G3D::VRApp::super
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.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
inherited

For use as the simulationStepDuration argument of setFrameDuration.

Enumerator
REAL_TIME 

Good for smooth animation in a high but variable-framerate system.

Advance simulation using wall-clock time.

Note that this will keep simulation running in "real-time" even when the system is running slowly (e.g., when recording video), which can lead to missed animation frames.

MATCH_REAL_TIME_TARGET 

Good for low frame rates when debugging, recording video, or working with a naive physics system.

Advance simulation by the same amount as the wallClockTargetDuration argument to setFrameDuration every frame, regardless of the actual time elapsed.

Note that when the system is running slowly, this ensures that rendering and simulation stay in lockstep with each other and no frames are dropped.

◆ Action

enum G3D::GApp::Action
inherited
Enumerator
ACTION_NONE 
ACTION_QUIT 
ACTION_SHOW_CONSOLE 

Constructor & Destructor Documentation

◆ VRApp()

G3D::VRApp::VRApp ( const GApp::Settings settings = VRApp::Settings())

The window will be forced to non-resizable.

◆ ~VRApp()

virtual G3D::VRApp::~VRApp ( )
virtual

Member Function Documentation

◆ activeCamera()

virtual const shared_ptr<Camera>& G3D::GApp::activeCamera ( ) const
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.

See also
activeListener

◆ activeListener()

const shared_ptr<Entity>& G3D::GApp::activeListener ( ) const
inlineinherited

May be nullptr.

◆ addAvatar()

virtual void G3D::VRApp::addAvatar ( )
protectedvirtual

Invoked by onAfterLoadScene to optionally create avatar parts unless the scene specifies otherwise.

See also
Scene::VRSettings::Avatar

◆ addWidget()

virtual void G3D::GApp::addWidget ( const shared_ptr< Widget > &  module,
bool  setFocus = true 
)
virtualinherited

Installs a module.

Actual insertion may be delayed until the next frame.

Referenced by G3D::GApp::setCameraManipulator().

◆ beginRun()

void G3D::GApp::beginRun ( )
protectedinherited

Initializes state at the beginning of onRun, including calling onCleanup.

◆ cameraManipulator()

shared_ptr<Manipulator> G3D::GApp::cameraManipulator ( ) const
inlineinherited

◆ createDeveloperHUD()

void G3D::GApp::createDeveloperHUD ( )
protectedinherited

Call from onInit to create the developer HUD.

◆ current()

static GApp* G3D::GApp::current ( )
staticinherited

Returns a pointer to the current GApp.

GApp sets itself as current upon construction

◆ debugCamera()

virtual const shared_ptr<Camera>& G3D::GApp::debugCamera ( ) const
inlinevirtualinherited

Exposes the debugging camera.

◆ decreaseEffects()

void G3D::VRApp::decreaseEffects ( )
protected

Called by maybeAdjustEffects when the frame rate is too low.

◆ drawDebugShapes()

virtual void G3D::GApp::drawDebugShapes ( )
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.

See also
debugDraw, Shape, DebugID, removeAllDebugShapes, removeDebugShape

◆ drawMessage()

virtual void G3D::GApp::drawMessage ( const String message)
virtualinherited

Draw a simple, short message in the center of the screen and swap the buffers.

Useful for loading screens and other slow operations.

◆ drawTitle()

void G3D::GApp::drawTitle ( const String title,
const String subtitle,
const Any any,
const Color3 fontColor,
const Color4 backColor 
)
inherited

Draws a title card.

◆ endRun()

void G3D::GApp::endRun ( )
protectedinherited

Cleans up at the end of onRun, including calling onCleanup.

◆ extendGBufferSpecification()

virtual void G3D::GApp::extendGBufferSpecification ( GBuffer::Specification spec)
protectedvirtualinherited

Ensures any GBuffer using.

Parameters
spechas 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.

See also
AmbientOcclusionSettings::extendGBufferSpecification

◆ frameDuration()

RealTime G3D::GApp::frameDuration ( ) const
inlineinherited

1.0 / desired frame rate

◆ gazeForEye()

const GazeTracker::Gaze& G3D::GApp::gazeForEye ( int  eye) const
inlineinherited

◆ gazeTracker()

const shared_ptr<GazeTracker>& G3D::GApp::gazeTracker ( ) const
inlineinherited

◆ graphicsWatch()

const Stopwatch& G3D::GApp::graphicsWatch ( ) const
inlineinherited

◆ headFrame()

virtual CFrame G3D::GApp::headFrame ( ) const
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.

◆ initializeOpenGL()

void G3D::GApp::initializeOpenGL ( RenderDevice rd,
OSWindow window,
bool  createWindowIfNull,
const Settings settings 
)
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.

◆ loadScene()

virtual void G3D::GApp::loadScene ( const String sceneName)
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.

◆ logicWatch()

const Stopwatch& G3D::GApp::logicWatch ( ) const
inlineinherited

◆ lowerFrameRateInBackground()

bool G3D::GApp::lowerFrameRateInBackground ( ) const
inlineinherited

◆ maybeAdjustEffects()

void G3D::VRApp::maybeAdjustEffects ( )
protected

If frame rate is being consistently missed, reduce the effects on activeCamera()

◆ maybeRemovePitchAndRoll()

CFrame G3D::VRApp::maybeRemovePitchAndRoll ( const CFrame source) const
protected

if m_cameraManipulator is a FirstPersonManipulator and m_trackingOverridesPitch is true, then zero out the pitch and roll in source

◆ networkWatch()

const Stopwatch& G3D::GApp::networkWatch ( ) const
inlineinherited

◆ onAfterEvents()

virtual void G3D::GApp::onAfterEvents ( )
protectedvirtualinherited

◆ onAfterLoadScene()

virtual void G3D::VRApp::onAfterLoadScene ( const Any any,
const String sceneName 
)
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.

◆ onAfterSimulation()

virtual void G3D::VRApp::onAfterSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
overridevirtual

Invoked after onSimulation is run on the installed GModules and GApp.

Not used by most programs.

Reimplemented from G3D::GApp.

◆ onAI()

virtual void G3D::GApp::onAI ( )
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.

◆ onBeforeSimulation()

virtual void G3D::VRApp::onBeforeSimulation ( RealTime rdt,
SimTime sdt,
SimTime idt 
)
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.

◆ onCleanup()

virtual void G3D::VRApp::onCleanup ( )
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.

◆ onConsoleCommand()

virtual void G3D::GApp::onConsoleCommand ( const String cmd)
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");
 }
 

◆ oneFrame()

virtual void G3D::GApp::oneFrame ( )
protectedvirtualinherited

A single frame of rendering, simulation, AI, events, networking, etc.

Invokes the onXXX methods and performs timing.

◆ onEvent()

virtual bool G3D::VRApp::onEvent ( const GEvent event)
overridevirtual

Support for toggling the HUD using the TAB key.

Reimplemented from G3D::GApp.

◆ onGraphics()

virtual void G3D::VRApp::onGraphics ( RenderDevice rd,
Array< shared_ptr< Surface > > &  surface,
Array< shared_ptr< Surface2D > > &  surface2D 
)
overridevirtual

Set up a double-eye call for onGraphics3D.

Reimplemented from G3D::GApp.

◆ onGraphics2D()

virtual void G3D::GApp::onGraphics2D ( RenderDevice rd,
Array< shared_ptr< Surface2D > > &  surface2D 
)
protectedvirtualinherited

Called from the default onGraphics.

◆ onGraphics3D()

virtual void G3D::GApp::onGraphics3D ( RenderDevice rd,
Array< shared_ptr< Surface > > &  surface 
)
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.

See also
G3D::GApp::m_renderer, G3D::Renderer

◆ onInit()

virtual void G3D::VRApp::onInit ( )
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.

◆ onNetwork()

virtual void G3D::GApp::onNetwork ( )
protectedvirtualinherited

For a networked app, override this to implement your network message polling.

◆ onPose()

virtual void G3D::GApp::onPose ( Array< shared_ptr< Surface > > &  posed3D,
Array< shared_ptr< Surface2D > > &  posed2D 
)
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.

◆ onPostProcessHDR3DEffects()

virtual void G3D::GApp::onPostProcessHDR3DEffects ( RenderDevice rd)
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.

◆ onRun()

void G3D::GApp::onRun ( )
protectedinherited

Helper for run() that actually starts the program loop.

Called from run().

◆ onSimulation()

virtual void G3D::GApp::onSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
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.

Parameters
rdtElapsed real-world time since the last call to onSimulation.
sdtElapsed sim-world time since the last call to onSimulation, computed by multiplying the wall-clock time by the simulation time rate.
idtElapsed 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.
See also
onBeforeSimulation, onAfterSimulation

◆ onUserInput()

virtual void G3D::GApp::onUserInput ( class UserInput userInput)
protectedvirtualinherited

Routine for processing user input from the previous frame.

Default implementation does nothing.

◆ onWait()

virtual void G3D::GApp::onWait ( RealTime  waitTime)
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)

◆ previousRealTimeStep()

RealTime G3D::GApp::previousRealTimeStep ( ) const
inlineinherited

Actual wall-clock time elapsed between the previous two frames.

See also
realTimeTargetDuration

◆ previousSimTimeStep()

SimTime G3D::GApp::previousSimTimeStep ( ) const
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.

◆ processGEventQueue()

virtual void G3D::GApp::processGEventQueue ( )
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.

◆ processTeleportation()

void G3D::VRApp::processTeleportation ( RealTime  rdt)
protected

◆ realTime()

RealTime G3D::GApp::realTime ( ) const
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().

◆ realTimeTargetDuration()

RealTime G3D::GApp::realTimeTargetDuration ( ) const
inlineinherited

1.0 / desired frame rate

Deprecated:

Referenced by G3D::GApp::setFrameDuration().

◆ removeAllDebugShapes()

void G3D::GApp::removeAllDebugShapes ( )
inherited

Clears all debug shapes, regardless of their pending display time.

See also
debugDraw, Shape, DebugID, removeDebugShape, drawDebugShapes

◆ removeDebugShape()

void G3D::GApp::removeDebugShape ( DebugID  id)
inherited

Clears just this debug shape (if it exists), regardless of its pending display time.

See also
debugDraw, Shape, DebugID, removeAllDebugShapes, drawDebugShapes

◆ removeWidget()

virtual void G3D::GApp::removeWidget ( const shared_ptr< Widget > &  module)
virtualinherited

The actual removal of the module may be delayed until the next frame.

Referenced by G3D::GApp::setCameraManipulator().

◆ renderCubeMap()

virtual void G3D::GApp::renderCubeMap ( RenderDevice rd,
Array< shared_ptr< Texture > > &  output,
const shared_ptr< Camera > &  camera,
const shared_ptr< Texture > &  depthMap,
int  resolution = 1024 
)
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.

Parameters
outputIf 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.
camerathe camera will have all of its parameters reset before the end of the call.
depthMapOptional 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:

Array<shared_ptr<Texture> > output;
renderCubeMap(renderDevice, output, defaultCamera);
const Texture::CubeMapInfo& cubeMapInfo = Texture::cubeMapInfo(CubeMapConvention::DIRECTX);
for (int f = 0; f < 6; ++f) {
const Texture::CubeMapInfo::Face& faceInfo = cubeMapInfo.face[f];
shared_ptr<Image> temp = output[f]->toImage(ImageFormat::RGB8());
temp->flipVertical();
temp->rotate90CW(-faceInfo.rotations);
if (faceInfo.flipY) { temp.flipVertical(); }
if (faceInfo.flipX) { temp.flipHorizontal(); }
temp->save(format("cube-%s.png", faceInfo.suffix.c_str()));
}

◆ renderer()

const shared_ptr<Renderer>& G3D::GApp::renderer ( )
inlineinherited

◆ resize()

virtual void G3D::GApp::resize ( int  w,
int  h 
)
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

◆ run()

int G3D::GApp::run ( )
inherited

Call this to run the app.

◆ sampleGazeTrackerData()

virtual void G3D::GApp::sampleGazeTrackerData ( )
protectedvirtualinherited

◆ saveScene()

virtual void G3D::GApp::saveScene ( )
virtualinherited

Save the current scene over the one on disk.

◆ scene()

const shared_ptr<Scene>& G3D::GApp::scene ( ) const
inlineinherited

◆ sceneVisualizationSettings()

virtual const SceneVisualizationSettings& G3D::GApp::sceneVisualizationSettings ( ) const
virtualinherited

◆ screenCapture()

ScreenCapture* G3D::GApp::screenCapture ( ) const
inlineinherited

◆ setActiveCamera()

virtual void G3D::VRApp::setActiveCamera ( const shared_ptr< Camera > &  camera)
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.

◆ setActiveListener()

virtual void G3D::GApp::setActiveListener ( const shared_ptr< Entity > &  listener)
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)").

See also
setActiveCamera

◆ setCameraManipulator()

void G3D::GApp::setCameraManipulator ( const shared_ptr< Manipulator > &  man)
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:

shared_ptr<UprightSplineManipulator> us = UprightSplineManipulator::create(debugCamera());
UprightSpline spline;
spline.extrapolationMode = SplineExtrapolationMode::CYCLIC;
spline.append(Point3(0,0,-3));
spline.append(Point3(1, 0, -3));
spline.append(Point3(0,0,-3));
spline.append(Point3(-1,0,-3));
us->setSpline(spline);
us->setMode(UprightSplineManipulator::Mode::PLAY_MODE);
app->setCameraManipulator(us);

◆ setCurrent()

static void G3D::GApp::setCurrent ( GApp gApp)
staticinherited

Sets the current GApp; the current GApp is used for debug drawing.

◆ setExitCode()

virtual void G3D::GApp::setExitCode ( int  code = 0)
virtualinherited

Invoke to true to end the program at the end of the next event loop.

◆ setFrameDuration()

virtual void G3D::GApp::setFrameDuration ( RealTime  realTimeTargetDuration,
SimTime  simulationStepDuration = MATCH_REAL_TIME_TARGET 
)
inlinevirtualinherited
Parameters
realTimeTargetDurationTarget 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.
setFrameDuration(1.0 / window()->settings().refreshRate);
Parameters
simulationStepDurationAmount 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.

◆ setLowerFrameRateInBackground()

virtual void G3D::GApp::setLowerFrameRateInBackground ( bool  s)
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.

◆ setRealTime()

virtual void G3D::GApp::setRealTime ( RealTime  r)
virtualinherited

◆ setScene()

virtual void G3D::GApp::setScene ( const shared_ptr< Scene > &  s)
inlineprotectedvirtualinherited

◆ setSimTime()

virtual void G3D::GApp::setSimTime ( SimTime  s)
virtualinherited

◆ setSimulationTimeScale()

virtual void G3D::GApp::setSimulationTimeScale ( float  s)
inlinevirtualinherited


Set the rate at which simulation time actually advances compared to the rate specified by setFrameDuration.

Set to 0 to pause simulation, 1 for normal behavior, and use other values when fast-forwarding (greater than 1) or showing slow-motion (less than 1).

◆ setSubmitToDisplayMode()

void G3D::GApp::setSubmitToDisplayMode ( SubmitToDisplayMode  m)
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.

◆ settings()

const Settings& G3D::GApp::settings ( ) const
inlineinherited

◆ show() [1/3]

shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< Texture > &  t,
const String windowCaption = "" 
)
inherited

Displays the texture in a new GuiWindow.

◆ show() [2/3]

shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< PixelTransferBuffer > &  t,
const String windowCaption = "" 
)
inherited

◆ show() [3/3]

shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< Image > &  t,
const String windowCaption = "" 
)
inherited

◆ showInTextureBrowser() [1/2]

shared_ptr<TextureBrowserWindow> G3D::GApp::showInTextureBrowser ( const String textureName,
Rect2D  rect = Rect2D::empty() 
)
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.

◆ showInTextureBrowser() [2/2]

shared_ptr<TextureBrowserWindow> G3D::GApp::showInTextureBrowser ( const shared_ptr< Texture > &  texture,
Rect2D  rect = Rect2D::empty() 
)
inherited

◆ simStepDuration()

SimTime G3D::GApp::simStepDuration ( ) const
inlineinherited

May also be REAL_TIME or MATCH_REAL_TIME_TARGET.

See also
previousSimTimeStep

◆ simTime()

SimTime G3D::GApp::simTime ( ) const
inlineinherited

In-simulation time since init was called on this applet.

Takes into account simTimeSpeed. Automatically incremented after ooSimulation.

◆ simulationTimeScale()

float G3D::GApp::simulationTimeScale ( ) const
inlineinherited

◆ simulationWatch()

const Stopwatch& G3D::GApp::simulationWatch ( ) const
inlineinherited

◆ staticConsoleCallback()

static void G3D::GApp::staticConsoleCallback ( const String command,
void *  me 
)
staticprotectedinherited

◆ submitToDisplayMode()

SubmitToDisplayMode G3D::GApp::submitToDisplayMode ( ) const
inlineprotectedinherited

◆ swapBuffers()

virtual void G3D::VRApp::swapBuffers ( )
overridevirtual

Intentionally empty so that subclasses don't accidentally swap buffers.

Simplifies upgrading existing apps to VRApps

Reimplemented from G3D::GApp.

◆ textureByName()

shared_ptr<Texture> G3D::GApp::textureByName ( const String name) const
inherited

Returns a texture by its name, or nullptr if not found.

Useful for bypassing language protection mechanisms when creating debugging GUIs

◆ typedScene()

template<class SceneSubclass = Scene>
shared_ptr<SceneSubclass> G3D::GApp::typedScene ( ) const
inlineinherited

◆ userInputWatch()

const Stopwatch& G3D::GApp::userInputWatch ( ) const
inlineinherited

◆ vrSubmitToDisplay()

virtual void G3D::VRApp::vrSubmitToDisplay ( )
protectedvirtual

VR equivalent of swapBuffers() for the HMD.

◆ vscreenPrintf()

void G3D::GApp::vscreenPrintf ( const char *  fmt,
va_list  argPtr 
)
inherited

◆ waitWatch()

const Stopwatch& G3D::GApp::waitWatch ( ) const
inlineinherited

◆ window()

OSWindow* G3D::GApp::window ( ) const
inlineinherited

Member Data Documentation

◆ catchCommonExceptions

bool G3D::GApp::catchCommonExceptions
inherited

When true, there is an assertion failure if an exception is thrown.

Default is true.

◆ console

GConsoleRef G3D::GApp::console
inherited

Command console.

Deprecated:

◆ dataDir

String G3D::GApp::dataDir
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.

◆ dataDirs

std::vector<String> G3D::GApp::dataDirs
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).

◆ dataDirsAddedToScene

bool G3D::GApp::dataDirsAddedToScene = false
inherited

◆ debugFont

shared_ptr<GFont> G3D::GApp::debugFont
inherited

nullptr if not loaded

◆ debugLabelArray

Array<DebugLabel> G3D::GApp::debugLabelArray
inherited

Labels to be rendered each frame, updated at the same times as debugShapeArray.

◆ debugPane

GuiPane* G3D::GApp::debugPane
inherited

debugWindow->pane()

◆ debugShapeArray

Array<DebugShape> G3D::GApp::debugShapeArray
inherited

Shapes to be rendered each frame.

Added to by G3D::debugDraw. Rendered by drawDebugShapes(); Automatically cleared once per frame.

◆ debugText

Array<String> G3D::GApp::debugText
protectedinherited

Strings that have been printed with screenPrintf.

Protected by m_debugTextMutex.

◆ debugWindow

shared_ptr<GuiWindow> G3D::GApp::debugWindow
inherited

Add your own debugging controls to this window.

◆ developerWindow

shared_ptr<DeveloperWindow> G3D::GApp::developerWindow
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.

◆ escapeKeyAction

Action G3D::GApp::escapeKeyAction
inherited

When true an GKey::ESCAPE keydown event quits the program.

(default is true)

◆ m_activeCamera

shared_ptr<Camera> G3D::GApp::m_activeCamera
protectedinherited

The currently selected camera.

See also
m_activeCameraMarker

Referenced by G3D::GApp::activeCamera().

◆ m_activeCameraMarker

shared_ptr<MarkerEntity> G3D::GApp::m_activeCameraMarker
protectedinherited

Follows the activeCamera.

In the Scene.

◆ m_activeListener

shared_ptr<Entity> G3D::GApp::m_activeListener
protectedinherited

◆ m_ambientOcclusion

shared_ptr<class AmbientOcclusion> G3D::GApp::m_ambientOcclusion
protectedinherited

Default/current AO object for the primary view, allocated in GApp::GApp.

◆ m_ambientOcclusionArray

shared_ptr<AmbientOcclusion> G3D::VRApp::m_ambientOcclusionArray[MAX_VIEWS]
protected

Per-eye.

◆ m_cameraManipulator

shared_ptr<Manipulator> G3D::GApp::m_cameraManipulator
protectedinherited

Used to find the frame for defaultCamera.

Referenced by G3D::GApp::cameraManipulator(), and G3D::GApp::setCameraManipulator().

◆ m_currentEyeIndex

int G3D::GApp::m_currentEyeIndex
protectedinherited

Set by onGraphics for each onGraphics3D call in VRApp.

Always 0 in GApp.

◆ m_cursorPointerTexture

shared_ptr<Texture> G3D::VRApp::m_cursorPointerTexture
protected

◆ m_debugCamera

shared_ptr<Camera> G3D::GApp::m_debugCamera
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().

◆ m_debugController

shared_ptr<FirstPersonManipulator> G3D::GApp::m_debugController
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);

◆ m_debugTextColor

Color4 G3D::GApp::m_debugTextColor
protectedinherited

◆ m_debugTextMutex

std::mutex G3D::GApp::m_debugTextMutex
protectedinherited

◆ m_debugTextOutlineColor

Color4 G3D::GApp::m_debugTextOutlineColor
protectedinherited

◆ m_debugTextWidget

shared_ptr<DebugTextWidget> G3D::GApp::m_debugTextWidget
protectedinherited

◆ m_depthOfField

shared_ptr<DepthOfField> G3D::GApp::m_depthOfField
protectedinherited

◆ m_depthPeelFramebuffer

shared_ptr<Framebuffer> G3D::GApp::m_depthPeelFramebuffer
protectedinherited

◆ m_deviceFramebuffer

shared_ptr<Framebuffer> G3D::GApp::m_deviceFramebuffer
protectedinherited

The current device [LDR] framebuffer.

This can be changed by GApp or VRApp just before invoking onGraphics3D. The default implementation of GApp sets it to m_osWindowDeviceFramebuffer.

◆ m_endProgram

bool G3D::GApp::m_endProgram
protectedinherited

◆ m_exitCode

int G3D::GApp::m_exitCode
protectedinherited

◆ m_film

shared_ptr<Film> G3D::GApp::m_film
protectedinherited

Allocated if GApp::Settings::FilmSettings::enabled was true when the constructor executed.

Automatically resized by resize() when the screen size changes.

◆ m_forceDiskFramebuffer

bool G3D::VRApp::m_forceDiskFramebuffer = true
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

◆ m_framebuffer

shared_ptr<Framebuffer> G3D::GApp::m_framebuffer
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].

◆ m_gaze

GazeTracker::Gaze* G3D::GApp::m_gaze
inherited

Gaze vector for the current eye, relative to the activeCamera().

This is a pointer into m_gazeArray

◆ m_gazeArray

GazeTracker::Gaze G3D::GApp::m_gazeArray[2]
inherited

Gaze for each eye for the current frame.

Referenced by G3D::GApp::gazeForEye().

◆ m_gazeTracker

shared_ptr<GazeTracker> G3D::GApp::m_gazeTracker
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().

◆ m_gbuffer

shared_ptr<GBuffer> G3D::GApp::m_gbuffer
protectedinherited

Bound to the current GBuffer, which is m_osWindowGBuffer by default.

See also
m_gbufferSpecification

◆ m_gbufferSpecification

GBuffer::Specification G3D::GApp::m_gbufferSpecification
protectedinherited

◆ m_graphicsWatch

Stopwatch G3D::GApp::m_graphicsWatch
protectedinherited

◆ m_highQualityWarping

bool G3D::VRApp::m_highQualityWarping
protected

Automatically turned on when the scene is loaded, disabled only if frame rate can't be maintained.

◆ m_hmdDeviceFramebuffer

shared_ptr<Framebuffer> G3D::VRApp::m_hmdDeviceFramebuffer[MAX_VIEWS]
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.

◆ m_hmdFilm

shared_ptr<Film> G3D::VRApp::m_hmdFilm[2]
protected

Per eye Film instance for VR.

onGraphics switches m_film between them.

◆ m_hmdGBuffer

shared_ptr<GBuffer> G3D::VRApp::m_hmdGBuffer[2]
protected

The active m_gbuffer is switched between these per eye.

That allows reprojection between them.

◆ m_hmdHDRFramebuffer

shared_ptr<Framebuffer> G3D::VRApp::m_hmdHDRFramebuffer[MAX_VIEWS]
protected

The HDR framebuffer used by G3D::Film for the HMD.

Comparable to GApp::monitorFramebuffer.

◆ m_hudBackgroundColor

Color4 G3D::VRApp::m_hudBackgroundColor
protected

Color of the HUD background, which reveals the boundaries of the virtual display.

◆ m_hudEnabled

float G3D::VRApp::m_hudEnabled
protected

If true, onGraphics2D is captured and displayed in the HMD.

By default, TAB toggles this.

◆ m_hudFrame

CFrame G3D::VRApp::m_hudFrame
protected

Position at which onGraphics2D renders on the virtual HUD layer if m_hudEnabled == true.

See also
VRApp::Settings::hudSpace

◆ m_hudWidth

float G3D::VRApp::m_hudWidth
protected

Width in meters of the HUD layer used to display onGraphics2D content in the HMD.

See also
VRApp::Settings::hudSpace

◆ m_lastDebugID

DebugID G3D::GApp::m_lastDebugID
inherited

Last DebugShape::id issued.

◆ m_lastFrameOverWait

RealTime G3D::GApp::m_lastFrameOverWait
protectedinherited

Used to track how much onWait overshot its desired target during the previous frame.

◆ m_lastTime

RealTime G3D::GApp::m_lastTime
protectedinherited

◆ m_lastWaitTime

RealTime G3D::GApp::m_lastWaitTime
protectedinherited

Used by onWait for elapsed time.

◆ m_logicWatch

Stopwatch G3D::GApp::m_logicWatch
protectedinherited

Referenced by G3D::GApp::logicWatch().

◆ m_lowerFrameRateInBackground

bool G3D::GApp::m_lowerFrameRateInBackground
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().

◆ m_maintainHeightOverGround

bool G3D::VRApp::m_maintainHeightOverGround = true
protected

If true, teleport the XR Tracked Volume as needed to maintain constant height above ground (as determined by ray casting).

◆ m_motionBlur

shared_ptr<MotionBlur> G3D::GApp::m_motionBlur
protectedinherited

◆ m_networkWatch

Stopwatch G3D::GApp::m_networkWatch
protectedinherited

Referenced by G3D::GApp::networkWatch().

◆ m_now

RealTime G3D::GApp::m_now
protectedinherited

Used by onSimulation for elapsed time.

◆ m_numSlowFrames

int G3D::VRApp::m_numSlowFrames
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.

◆ m_osWindowDeviceFramebuffer

shared_ptr<Framebuffer> G3D::GApp::m_osWindowDeviceFramebuffer
protectedinherited

The (probably low dynamic range, one sample per pixel) OpenGL hardware framebuffer for the window().

Initialized in initializeOpenGL().

See also
VRApp::m_hmdDeviceFramebuffer[]

◆ m_osWindowGBuffer

shared_ptr<GBuffer> G3D::GApp::m_osWindowGBuffer
protectedinherited

GBuffer used for the OSWindow.

VRApp adds per-eye HMD GBuffers

◆ m_osWindowHDRFramebuffer

shared_ptr<Framebuffer> G3D::GApp::m_osWindowHDRFramebuffer
protectedinherited

Framebuffer used for rendering the 3D portion of the scene.

Includes a color guard band. This is then resolved to m_osWindowDeviceFramebuffer.

See also
G3D::GApp::Settings::HDRFramebufferSettings

◆ m_posed2D

Array<shared_ptr<Surface2D> > G3D::GApp::m_posed2D
protectedinherited

◆ m_posed3D

Array<shared_ptr<Surface> > G3D::GApp::m_posed3D
protectedinherited

◆ m_poseWatch

Stopwatch G3D::GApp::m_poseWatch
protectedinherited

◆ m_previousRealTimeStep

float G3D::GApp::m_previousRealTimeStep
protectedinherited

◆ m_previousSimTimeStep

float G3D::GApp::m_previousSimTimeStep
protectedinherited

◆ m_realTime

RealTime G3D::GApp::m_realTime
protectedinherited

Referenced by G3D::GApp::realTime().

◆ m_renderer

shared_ptr<Renderer> G3D::GApp::m_renderer
protectedinherited

Used by the default onGraphics3D to render Surfaces.

Referenced by G3D::GApp::renderer().

◆ m_renderPeriod

int G3D::GApp::m_renderPeriod
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.

◆ m_settings

Settings G3D::GApp::m_settings
protectedinherited

The original settings.

Referenced by G3D::GApp::settings().

◆ m_simTime

SimTime G3D::GApp::m_simTime
protectedinherited

Referenced by G3D::GApp::simTime().

◆ m_simTimeScale

float G3D::GApp::m_simTimeScale
protectedinherited

◆ m_simTimeStep

float G3D::GApp::m_simTimeStep
protectedinherited

SimTime seconds per frame,.

See also
setFrameDuration, m_simTimeScale

Referenced by G3D::GApp::setFrameDuration(), and G3D::GApp::simStepDuration().

◆ m_simulationWatch

Stopwatch G3D::GApp::m_simulationWatch
protectedinherited

◆ m_userInputWatch

Stopwatch G3D::GApp::m_userInputWatch
protectedinherited

◆ m_vrSubmitToDisplayMode

SubmitToDisplayMode G3D::VRApp::m_vrSubmitToDisplayMode
protected

◆ m_waitWatch

Stopwatch G3D::GApp::m_waitWatch
protectedinherited

Referenced by G3D::GApp::waitWatch().

◆ m_wallClockTargetDuration

float G3D::GApp::m_wallClockTargetDuration
protectedinherited

Seconds per frame target for the entire system.

See also
setFrameDuration

Referenced by G3D::GApp::frameDuration(), G3D::GApp::realTimeTargetDuration(), and G3D::GApp::setFrameDuration().

◆ m_widgetManager

shared_ptr<WidgetManager> G3D::GApp::m_widgetManager
protectedinherited

◆ m_xrSystem

shared_ptr<XR> G3D::GApp::m_xrSystem
protectedinherited

The low-level XR API.

VRApp mostly communicates through an XRWidget that wraps this, but needs the underlying system for initialization and cleanup.

◆ m_xrWidget

shared_ptr<XRWidget> G3D::GApp::m_xrWidget
protectedinherited

◆ manageUserInput

bool G3D::GApp::manageUserInput
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)

◆ MAX_SLOW_FRAMES

const int G3D::VRApp::MAX_SLOW_FRAMES = 20
staticprotected
See also
m_numSlowFrames

◆ MAX_VIEWS

const unsigned int G3D::VRApp::MAX_VIEWS = 4
staticprotected

Maximum number of views ("eyes") for HMD 0.

◆ renderDevice

RenderDevice* G3D::GApp::renderDevice
inherited

◆ s_currentGApp

GApp* G3D::GApp::s_currentGApp
staticprotectedinherited

Pointer to the current GApp.

GApp sets itself as current upon construction

◆ showDebugText

bool G3D::GApp::showDebugText
inherited

When true, screenPrintf prints to the screen.

(default is true)

◆ showRenderingStats

bool G3D::GApp::showRenderingStats
inherited

When true, debugTextWidget prints the frame rate and other data to the screen.

◆ userInput

UserInput* G3D::GApp::userInput
inherited

documentation generated on Wed Nov 24 2021 08:02:02 using doxygen 1.8.15