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


Optional base class for quickly creating 3D applications. More...

Inherited by G3D::VRApp.

Classes

class  DebugLabel
 
class  DebugShape
 
class  DebugVRMirrorMode
 
class  Settings
 
class  SubmitToDisplayMode
 

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

 GApp (const Settings &options=Settings(), OSWindow *window=nullptr, RenderDevice *rd=nullptr, bool createWindowOnNull=true)
 
virtual ~GApp ()
 
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)
 Invoked by loadScene() after the scene has been loaded. 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)
 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 ()
 
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 Member Functions

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 endRun ()
 Cleans up at the end of onRun, including calling onCleanup. More...
 
virtual void extendGBufferSpecification (GBuffer::Specification &spec)
 Ensures any GBuffer using. More...
 
virtual void onAfterEvents ()
 
virtual void onAfterSimulation (RealTime rdt, SimTime sdt, SimTime idt)
 Invoked after onSimulation is run on the installed GModules and GApp. More...
 
virtual void onAI ()
 Update any state you need to here. More...
 
virtual void onBeforeSimulation (RealTime &rdt, SimTime &sdt, SimTime &idt)
 Invoked before onSimulation is run on the installed GModules and GApp. More...
 
virtual void onCleanup ()
 Unload/deallocate your data 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 bool onEvent (const GEvent &event)
 It is recommended to override onUserInput() instead of this method. More...
 
virtual void onGraphics (RenderDevice *rd, Array< shared_ptr< Surface > > &surface, Array< shared_ptr< Surface2D > > &surface2D)
 Rendering callback used to paint the screen. 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 onInit ()
 Load your data here. 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...
 
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
 

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< 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< 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...
 
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
 
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...
 
shared_ptr< MotionBlurm_motionBlur
 
Stopwatch m_networkWatch
 
RealTime m_now
 Used by onSimulation for elapsed time. 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
 
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 GApps_currentGApp
 Pointer to the current GApp. More...
 

Friends

class DebugTextWidget
 
class DeveloperWindow
 
class OSWindow
 
class SceneEditorWindow
 
class Shader
 

Detailed Description


Optional base class for quickly creating 3D applications.

GApp has several event handlers implemented as virtual methods. It invokes these in a cooperative, round-robin fashion. This avoids the need for threads in most applications. The methods are, in order of invocation from GApp::oneFrame:

To customize the rendering algorithm without modifying the post-processing setup, you can use the default GApp::onGraphics3D and simply change the GApp::m_renderer by subclassing G3D::Renderer.

The GApp::run method starts the main loop. It invokes GApp::onInit, runs the main loop until completion, and then invokes GApp::onCleanup.

onWait runs before onGraphics because the beginning of onGraphics causes the CPU to block, waiting for the GPU to complete the previous frame.

When you override a method, invoke the GApp version of that method to ensure that Widgets still work properly. This allows you to control whether your per-app operations occur before or after the Widget ones.

There are a number of framebuffers:

See also
GApp::Settings, OSWindow, RenderDevice, G3D_START_AT_MAIN

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

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

Enumerator
ACTION_NONE 
ACTION_QUIT 
ACTION_SHOW_CONSOLE 

Constructor & Destructor Documentation

◆ GApp()

G3D::GApp::GApp ( const Settings options = Settings(),
OSWindow window = nullptr,
RenderDevice rd = nullptr,
bool  createWindowOnNull = true 
)
Parameters
windowIf null, an OSWindow will be created for you. This argument is useful for substituting a different window system (e.g., GlutWindow)
createWindowOnNullCreate the window or renderDevice if they are nullptr. Setting createWindowOnNull = false allows a subclass to explicitly decide when to invoke those calls.

◆ ~GApp()

virtual G3D::GApp::~GApp ( )
virtual

Member Function Documentation

◆ activeCamera()

virtual const shared_ptr<Camera>& G3D::GApp::activeCamera ( ) const
inlinevirtual

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
inline

May be nullptr.

◆ addWidget()

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

Installs a module.

Actual insertion may be delayed until the next frame.

Referenced by setCameraManipulator().

◆ beginRun()

void G3D::GApp::beginRun ( )
protected

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

◆ cameraManipulator()

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

◆ createDeveloperHUD()

void G3D::GApp::createDeveloperHUD ( )
protected

Call from onInit to create the developer HUD.

◆ current()

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

Returns a pointer to the current GApp.

GApp sets itself as current upon construction

◆ debugCamera()

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

Exposes the debugging camera.

◆ drawDebugShapes()

virtual void G3D::GApp::drawDebugShapes ( )
virtual

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)
virtual

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 
)

Draws a title card.

◆ endRun()

void G3D::GApp::endRun ( )
protected

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

◆ extendGBufferSpecification()

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

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
inline

1.0 / desired frame rate

◆ gazeForEye()

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

◆ gazeTracker()

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

◆ graphicsWatch()

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

◆ headFrame()

virtual CFrame G3D::GApp::headFrame ( ) const
virtual

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 
)

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)
virtual

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
inline

◆ lowerFrameRateInBackground()

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

◆ networkWatch()

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

◆ onAfterEvents()

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

◆ onAfterLoadScene()

virtual void G3D::GApp::onAfterLoadScene ( const Any any,
const String sceneName 
)
inlinevirtual

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

◆ onAfterSimulation()

virtual void G3D::GApp::onAfterSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
protectedvirtual

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

Not used by most programs.

Reimplemented in G3D::VRApp.

◆ onAI()

virtual void G3D::GApp::onAI ( )
protectedvirtual

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::GApp::onBeforeSimulation ( RealTime rdt,
SimTime sdt,
SimTime idt 
)
protectedvirtual

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

◆ onCleanup()

virtual void G3D::GApp::onCleanup ( )
protectedvirtual

Unload/deallocate your data here.

Unlike the destructor, this catches common exceptions. It is called after the last frame is processed.

Reimplemented in G3D::VRApp.

◆ onConsoleCommand()

virtual void G3D::GApp::onConsoleCommand ( const String cmd)
protectedvirtual

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 ( )
protectedvirtual

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

Invokes the onXXX methods and performs timing.

◆ onEvent()

virtual bool G3D::GApp::onEvent ( const GEvent event)
protectedvirtual

It is recommended to override onUserInput() instead of this method.

Override if you need to explicitly handle events raw in the order they appear rather than once per frame by checking the current system state.

Note that the userInput contains a record of all keys pressed/held, mouse, and joystick state, so you do not have to override this method to handle basic input events.

Return true if the event has been consumed (i.e., no-one else including GApp should process it further).

The default implementation does nothing.

This runs after the m_widgetManager's onEvent, so a widget may consume events before the App sees them.

Reimplemented in G3D::VRApp.

◆ onGraphics()

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

Rendering callback used to paint the screen.

Called automatically. RenderDevice::beginFrame and endFrame are called for you before this is invoked.

The default implementation calls onGraphics2D and onGraphics3D.

Reimplemented in G3D::VRApp.

◆ onGraphics2D()

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

Called from the default onGraphics.

◆ onGraphics3D()

virtual void G3D::GApp::onGraphics3D ( RenderDevice rd,
Array< shared_ptr< Surface > > &  surface 
)
protectedvirtual

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::GApp::onInit ( )
protectedvirtual

Load your data here.

Unlike the constructor, this catches common exceptions. It is called before the first frame is processed.

Reimplemented in G3D::VRApp.

◆ onNetwork()

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

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 
)
protectedvirtual

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)
protectedvirtual

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 ( )
protected

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

Called from run().

◆ onSimulation()

virtual void G3D::GApp::onSimulation ( RealTime  rdt,
SimTime  sdt,
SimTime  idt 
)
protectedvirtual

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)
protectedvirtual

Routine for processing user input from the previous frame.

Default implementation does nothing.

◆ onWait()

virtual void G3D::GApp::onWait ( RealTime  waitTime)
protectedvirtual

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
inline

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

See also
realTimeTargetDuration

◆ previousSimTimeStep()

SimTime G3D::GApp::previousSimTimeStep ( ) const
inline

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 ( )
protectedvirtual

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.

◆ realTime()

RealTime G3D::GApp::realTime ( ) const
inline

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
inline

1.0 / desired frame rate

Deprecated:

Referenced by setFrameDuration().

◆ removeAllDebugShapes()

void G3D::GApp::removeAllDebugShapes ( )

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

See also
debugDraw, Shape, DebugID, removeDebugShape, drawDebugShapes

◆ removeDebugShape()

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

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)
virtual

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

Referenced by 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 
)
protectedvirtual

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 ( )
inline

◆ resize()

virtual void G3D::GApp::resize ( int  w,
int  h 
)
protectedvirtual

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 ( )

Call this to run the app.

◆ sampleGazeTrackerData()

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

◆ saveScene()

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

Save the current scene over the one on disk.

◆ scene()

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

◆ sceneVisualizationSettings()

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

◆ screenCapture()

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

◆ setActiveCamera()

virtual void G3D::GApp::setActiveCamera ( const shared_ptr< Camera > &  camera)
virtual

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

◆ setActiveListener()

virtual void G3D::GApp::setActiveListener ( const shared_ptr< Entity > &  listener)
inlinevirtual

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)
inline

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)
static

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

◆ setExitCode()

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

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 
)
inlinevirtual
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)
inlinevirtual

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)
virtual

◆ setScene()

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

◆ setSimTime()

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

◆ setSimulationTimeScale()

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


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)
inlineprotected

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
inline

◆ show() [1/3]

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

Displays the texture in a new GuiWindow.

◆ show() [2/3]

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

◆ show() [3/3]

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

◆ showInTextureBrowser() [1/2]

shared_ptr<TextureBrowserWindow> G3D::GApp::showInTextureBrowser ( const String textureName,
Rect2D  rect = Rect2D::empty() 
)

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() 
)

◆ simStepDuration()

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

May also be REAL_TIME or MATCH_REAL_TIME_TARGET.

See also
previousSimTimeStep

◆ simTime()

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

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

Takes into account simTimeSpeed. Automatically incremented after ooSimulation.

◆ simulationTimeScale()

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

◆ simulationWatch()

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

◆ staticConsoleCallback()

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

◆ submitToDisplayMode()

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

◆ swapBuffers()

virtual void G3D::GApp::swapBuffers ( )
virtual

Reimplemented in G3D::VRApp.

◆ textureByName()

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

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
inline

◆ userInputWatch()

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

◆ vscreenPrintf()

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

◆ waitWatch()

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

◆ window()

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

Friends And Related Function Documentation

◆ DebugTextWidget

friend class DebugTextWidget
friend

◆ DeveloperWindow

friend class DeveloperWindow
friend

◆ OSWindow

friend class OSWindow
friend

◆ SceneEditorWindow

friend class SceneEditorWindow
friend

◆ Shader

friend class Shader
friend

Member Data Documentation

◆ catchCommonExceptions

bool G3D::GApp::catchCommonExceptions

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

Default is true.

◆ console

GConsoleRef G3D::GApp::console

Command console.

Deprecated:

◆ dataDir

String G3D::GApp::dataDir

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

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

◆ debugFont

shared_ptr<GFont> G3D::GApp::debugFont

nullptr if not loaded

◆ debugLabelArray

Array<DebugLabel> G3D::GApp::debugLabelArray

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

◆ debugPane

GuiPane* G3D::GApp::debugPane

debugWindow->pane()

◆ debugShapeArray

Array<DebugShape> G3D::GApp::debugShapeArray

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
protected

Strings that have been printed with screenPrintf.

Protected by m_debugTextMutex.

◆ debugWindow

shared_ptr<GuiWindow> G3D::GApp::debugWindow

Add your own debugging controls to this window.

◆ developerWindow

shared_ptr<DeveloperWindow> G3D::GApp::developerWindow

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

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

(default is true)

◆ m_activeCamera

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

The currently selected camera.

See also
m_activeCameraMarker

Referenced by activeCamera().

◆ m_activeCameraMarker

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

Follows the activeCamera.

In the Scene.

◆ m_activeListener

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

◆ m_ambientOcclusion

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

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

◆ m_cameraManipulator

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

Used to find the frame for defaultCamera.

Referenced by cameraManipulator(), and setCameraManipulator().

◆ m_currentEyeIndex

int G3D::GApp::m_currentEyeIndex
protected

Set by onGraphics for each onGraphics3D call in VRApp.

Always 0 in GApp.

◆ m_debugCamera

shared_ptr<Camera> G3D::GApp::m_debugCamera
protected

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 debugCamera().

◆ m_debugController

shared_ptr<FirstPersonManipulator> G3D::GApp::m_debugController
protected

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
protected

◆ m_debugTextMutex

std::mutex G3D::GApp::m_debugTextMutex
protected

◆ m_debugTextOutlineColor

Color4 G3D::GApp::m_debugTextOutlineColor
protected

◆ m_debugTextWidget

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

◆ m_depthOfField

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

◆ m_depthPeelFramebuffer

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

◆ m_deviceFramebuffer

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

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
protected

◆ m_exitCode

int G3D::GApp::m_exitCode
protected

◆ m_film

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

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

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

◆ m_framebuffer

shared_ptr<Framebuffer> G3D::GApp::m_framebuffer
protected

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

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]

Gaze for each eye for the current frame.

Referenced by gazeForEye().

◆ m_gazeTracker

shared_ptr<GazeTracker> G3D::GApp::m_gazeTracker

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 gazeTracker().

◆ m_gbuffer

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

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

See also
m_gbufferSpecification

◆ m_gbufferSpecification

GBuffer::Specification G3D::GApp::m_gbufferSpecification
protected

◆ m_graphicsWatch

Stopwatch G3D::GApp::m_graphicsWatch
protected

Referenced by graphicsWatch().

◆ m_lastDebugID

DebugID G3D::GApp::m_lastDebugID

Last DebugShape::id issued.

◆ m_lastFrameOverWait

RealTime G3D::GApp::m_lastFrameOverWait
protected

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

◆ m_lastTime

RealTime G3D::GApp::m_lastTime
protected

◆ m_lastWaitTime

RealTime G3D::GApp::m_lastWaitTime
protected

Used by onWait for elapsed time.

◆ m_logicWatch

Stopwatch G3D::GApp::m_logicWatch
protected

Referenced by logicWatch().

◆ m_lowerFrameRateInBackground

bool G3D::GApp::m_lowerFrameRateInBackground
protected

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 lowerFrameRateInBackground(), and setLowerFrameRateInBackground().

◆ m_motionBlur

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

◆ m_networkWatch

Stopwatch G3D::GApp::m_networkWatch
protected

Referenced by networkWatch().

◆ m_now

RealTime G3D::GApp::m_now
protected

Used by onSimulation for elapsed time.

◆ m_osWindowDeviceFramebuffer

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

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
protected

GBuffer used for the OSWindow.

VRApp adds per-eye HMD GBuffers

◆ m_osWindowHDRFramebuffer

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

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
protected

◆ m_posed3D

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

◆ m_poseWatch

Stopwatch G3D::GApp::m_poseWatch
protected

◆ m_previousRealTimeStep

float G3D::GApp::m_previousRealTimeStep
protected

Referenced by previousRealTimeStep().

◆ m_previousSimTimeStep

float G3D::GApp::m_previousSimTimeStep
protected

Referenced by previousSimTimeStep().

◆ m_realTime

RealTime G3D::GApp::m_realTime
protected

Referenced by realTime().

◆ m_renderer

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

Used by the default onGraphics3D to render Surfaces.

Referenced by renderer().

◆ m_renderPeriod

int G3D::GApp::m_renderPeriod
protected

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
protected

The original settings.

Referenced by settings().

◆ m_simTime

SimTime G3D::GApp::m_simTime
protected

Referenced by simTime().

◆ m_simTimeScale

float G3D::GApp::m_simTimeScale
protected

◆ m_simTimeStep

float G3D::GApp::m_simTimeStep
protected

SimTime seconds per frame,.

See also
setFrameDuration, m_simTimeScale

Referenced by setFrameDuration(), and simStepDuration().

◆ m_simulationWatch

Stopwatch G3D::GApp::m_simulationWatch
protected

Referenced by simulationWatch().

◆ m_userInputWatch

Stopwatch G3D::GApp::m_userInputWatch
protected

Referenced by userInputWatch().

◆ m_waitWatch

Stopwatch G3D::GApp::m_waitWatch
protected

Referenced by waitWatch().

◆ m_wallClockTargetDuration

float G3D::GApp::m_wallClockTargetDuration
protected

Seconds per frame target for the entire system.

See also
setFrameDuration

Referenced by frameDuration(), realTimeTargetDuration(), and setFrameDuration().

◆ m_widgetManager

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

◆ m_xrSystem

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

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
protected

◆ manageUserInput

bool G3D::GApp::manageUserInput

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)

◆ renderDevice

RenderDevice* G3D::GApp::renderDevice

◆ s_currentGApp

GApp* G3D::GApp::s_currentGApp
staticprotected

Pointer to the current GApp.

GApp sets itself as current upon construction

◆ showDebugText

bool G3D::GApp::showDebugText

When true, screenPrintf prints to the screen.

(default is true)

◆ showRenderingStats

bool G3D::GApp::showRenderingStats

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

◆ userInput

UserInput* G3D::GApp::userInput

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