Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::GApp Class Reference

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

Classes

class  DebugShape
 
class  Settings
 

Public Types

enum  Action {
  ACTION_NONE,
  ACTION_QUIT,
  ACTION_SHOW_CONSOLE
}
 

Public Member Functions

 GApp (const Settings &options=Settings(), OSWindow *window=NULL)
 
virtual ~GApp ()
 
virtual shared_ptr< CameraactiveCamera ()
 The currently active camera for the primary view.
 
virtual const shared_ptr< CameraactiveCamera () const
 
virtual void addWidget (const Widget::Ref &module, bool setFocus=true)
 Installs a module.
 
Manipulator::Ref cameraManipulator () const
 
virtual shared_ptr< CameradebugCamera ()
 Exposes the debugging camera.
 
RealTime desiredFrameDuration () const
 
float desiredFrameRate () const
 
void drawDebugShapes ()
 Draw everything in debugShapeArray.
 
void drawMessage (const std::string &message)
 Draw a simple, short message in the center of the screen and swap the buffers.
 
const StopwatchgraphicsWatch () const
 
virtual void loadScene (const std::string &sceneName)
 Load a new scene.
 
const StopwatchlogicWatch () const
 
bool lowerFrameRateInBackground () const
 
const StopwatchnetworkWatch () const
 
RealTime realTime () const
 Accumulated wall-clock time since init was called on this applet.
 
void removeAllDebugShapes ()
 Clears all debug shapes, regardless of their pending display time.
 
void removeDebugShape (DebugID id)
 Clears just this debug shape (if it exists), regardless of its pending display time.
 
virtual void removeWidget (const Widget::Ref &module)
 The actual removal of the module may be delayed until the next frame.
 
virtual void renderDebugInfo ()
 Called from GApplet::run immediately after doGraphics to render the debugging text.
 
int run ()
 Call this to run the app.
 
virtual void saveScene ()
 Save the current scene over the one on disk.
 
virtual void setActiveCamera (const shared_ptr< Camera > &camera)
 
void setCameraManipulator (const Manipulator::Ref &man)
 The manipulator that positions the debugCamera every frame.
 
virtual void setDesiredFrameRate (float fps)
 Change to invoke frame limiting via onWait.
 
virtual void setExitCode (int code=0)
 Invoke to true to end the program at the end of the next event loop.
 
virtual void setLowerFramerateInBackground (bool s)
 If true, the desired frame rate is ignored when the OSWindow does not have focus and the program switches to running 4fps.
 
virtual void setRealTime (RealTime r)
 
virtual void setSimTime (SimTime s)
 
virtual void setSimTimeStep (float s)
 
shared_ptr< GuiWindowshow (const shared_ptr< Texture > &t, const std::string &windowCaption="")
 Displays the texture in a new GuiWindow.
 
shared_ptr< GuiWindowshow (const shared_ptr< PixelTransferBuffer > &t, const std::string &windowCaption="")
 
shared_ptr< GuiWindowshow (const shared_ptr< Image > &t, const std::string &windowCaption="")
 
SimTime simTime () const
 In-simulation time since init was called on this applet.
 
float simTimeStep () const
 Elapsed time per RENDERED frame for ideal simulation.
 
const StopwatchsimulationWatch () const
 
const StopwatchuserInputWatch () const
 
void vscreenPrintf (const char *fmt, va_list argPtr) G3D_CHECK_VPRINTF_METHOD_ARGS
 
const StopwatchwaitWatch () const
 
OSWindowwindow () const
 

Static Public Member Functions

static shared_ptr< class LightingdefaultLighting ()
 
Creates a default lighting environment for demos, which uses the file

on the noonclouds/noonclouds_*.jpg textures.

 

Public Attributes

bool catchCommonExceptions
 When true, there is an assertion failure if an exception is thrown.
 
GConsoleRef console
 Command console.
 
std::string dataDir
 Initialized to GApp::Settings::dataDir, or if that is "<AUTO>", to System::demoFindData().
 
shared_ptr< GFontdebugFont
 NULL if not loaded.
 
GuiPanedebugPane
 debugWindow->pane()
 
Array< DebugShapedebugShapeArray
 Shapes to be rendered each frame.
 
GuiWindow::Ref debugWindow
 Add your own debugging controls to this window.
 
DeveloperWindow::Ref developerWindow
 The window that displays buttons for debugging.
 
Action escapeKeyAction
 When true an GKey::ESCAPE keydown event quits the program.
 
bool fastSwitchCamera
 When true GKey::F2 keydown deactivates the camera and restores the mouse cursor.
 
DebugID m_lastDebugID
 Last DebugShape::id issued.
 
bool manageUserInput
 When true, the G3D::UserInput->beginEvents/endEvents processing is handled for you by calling processGEventQueue() before G3D::GApp::onUserInput is called.
 
RenderDevicerenderDevice
 
bool showDebugText
 When true, debugPrintf prints to the screen.
 
bool showRenderingStats
 When true, renderDebugInfo prints the frame rate and other data to the screen.
 
UserInputuserInput
 

Protected Member Functions

CoordinateFrame bookmark (const std::string &name, const CoordinateFrame &defaultValue=CoordinateFrame()) const
 Shorthand for developerWindow->cameraControlWindow->bookmark(name)
 
void createDeveloperHUD (const shared_ptr< Scene > &scene=shared_ptr< Scene >())
 Call from onInit to create the developer HUD.
 
virtual void onAfterSimulation (RealTime rdt, SimTime sdt, SimTime idt)
 Invoked after onSimulation is run on the installed GModules and GApp.
 
virtual void onAI ()
 Update any state you need to here.
 
virtual void onBeforeSimulation (RealTime &rdt, SimTime &sdt, SimTime &idt)
 Invoked before onSimulation is run on the installed GModules and GApp.
 
virtual void onCleanup ()
 Unload/deallocate your data here.
 
virtual void onConsoleCommand (const std::string &cmd)
 Invoked when a user presses enter in the in-game console.
 
virtual bool onEvent (const GEvent &event)
 It is recommended to override onUserInput() instead of this method.
 
virtual void onGraphics (RenderDevice *rd, Array< shared_ptr< Surface > > &surface, Array< shared_ptr< Surface2D > > &surface2D)
 Rendering callback used to paint the screen.
 
virtual void onGraphics2D (RenderDevice *rd, Array< shared_ptr< Surface2D > > &surface2D)
 Called from the default onGraphics.
 
virtual void onGraphics3D (RenderDevice *rd, Array< shared_ptr< Surface > > &surface)
 Called from the default onGraphics.
 
virtual void onInit ()
 Load your data here.
 
virtual void onNetwork ()
 For a networked app, override this to implement your network message polling.
 
virtual void onPose (Array< shared_ptr< Surface > > &posed3D, Array< shared_ptr< Surface2D > > &posed2D)
 Called before onGraphics.
 
virtual void onSimulation (RealTime rdt, SimTime sdt, SimTime idt)
 Override this with your simulation code.
 
virtual void onUserInput (class UserInput *userInput)
 Routine for processing user input from the previous frame.
 
virtual void onWait (RealTime waitTime)
 Task to be used for frame rate limiting.
 
virtual void processGEventQueue ()
 Processes all pending events on the OSWindow queue into the userInput.
 
virtual void renderCubeMap (RenderDevice *rd, Array< shared_ptr< Texture > > &output, const shared_ptr< Camera > &camera, shared_ptr< Texture > depthMap=shared_ptr< Texture >(), int resolution=1024)
 Helper for generating cube maps.
 
void resize (int w, int h)
 Change the size of the underlying Film.
 

Static Protected Member Functions

static void staticConsoleCallback (const std::string &command, void *me)
 

Protected Attributes

Array< std::stringdebugText
 Strings that have been printed with screenPrintf.
 
shared_ptr< Cameram_activeCamera
 The currently selected camera.
 
shared_ptr< class
AmbientOcclusion
m_ambientOcclusion
 Default AO object for the primary view, allocated in GApp::GApp.
 
shared_ptr< Manipulatorm_cameraManipulator
 Used to find the frame for defaultCamera.
 
shared_ptr< Texturem_colorBuffer0
 Always bound to m_frameBuffer FrameBuffer::COLOR0.
 
shared_ptr< Cameram_debugCamera
 A camera that is driven by the debugController.
 
shared_ptr
< FirstPersonManipulator
m_debugController
 Allows first person (Quake game-style) control using the arrow keys or W,A,S,D and the mouse.
 
Color4 m_debugTextColor
 
GMutex m_debugTextMutex
 
Color4 m_debugTextOutlineColor
 
shared_ptr< Texturem_depthBuffer
 Always bound to m_frameBuffer FrameBuffer::DEPTH.
 
shared_ptr< DepthOfFieldm_depthOfField
 
shared_ptr< Renderbufferm_depthRenderBuffer
 Always bound to m_frameBuffer FrameBuffer::DEPTH.
 
bool m_endProgram
 
int m_exitCode
 
shared_ptr< Filmm_film
 Allocated if GApp::Settings::FilmSettings::enabled was true when the constructor executed.
 
shared_ptr< Framebufferm_frameBuffer
 Framebuffer used for rendering the 3D portion of the scene.
 
shared_ptr< GBufferm_gbuffer
 NULL by default.
 
Stopwatch m_graphicsWatch
 
RealTime m_lastFrameOverWait
 Used to track how much onWait overshot its desired target during the previous frame.
 
Stopwatch m_logicWatch
 
shared_ptr< MotionBlurm_motionBlur
 
Stopwatch m_networkWatch
 
Array< Surface2DRefm_posed2D
 
Array< shared_ptr< Surface > > m_posed3D
 
Stopwatch m_poseWatch
 
int m_renderPeriod
 onPose(), onGraphics(), and onWait() execute once ever m_renderPeriod simulation frames.
 
Settings m_settings
 The original settings.
 
Stopwatch m_simulationWatch
 
Stopwatch m_userInputWatch
 
Stopwatch m_waitWatch
 
shared_ptr< WidgetManagerm_widgetManager
 

Friends

class DeveloperWindow
 
class OSWindow
 
class VideoRecordDialog
 

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:

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.

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

Member Enumeration Documentation

Enumerator:
ACTION_NONE 
ACTION_QUIT 
ACTION_SHOW_CONSOLE 

Constructor & Destructor Documentation

G3D::GApp::GApp ( const Settings options = Settings(),
OSWindow window = NULL 
)
Parameters
windowIf null, a SDLWindow will be created for you. This argument is useful for substituting a different window system (e.g. GlutWindow)
virtual G3D::GApp::~GApp ( )
virtual

Member Function Documentation

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

The currently active camera for the primary view.

virtual const shared_ptr<Camera> G3D::GApp::activeCamera ( ) const
inlinevirtual
virtual void G3D::GApp::addWidget ( const Widget::Ref module,
bool  setFocus = true 
)
virtual

Installs a module.

Actual insertion may be delayed until the next frame.

CoordinateFrame G3D::GApp::bookmark ( const std::string name,
const CoordinateFrame defaultValue = CoordinateFrame() 
) const
protected

Shorthand for developerWindow->cameraControlWindow->bookmark(name)

Manipulator::Ref G3D::GApp::cameraManipulator ( ) const
inline
void G3D::GApp::createDeveloperHUD ( const shared_ptr< Scene > &  scene = shared_ptr< Scene >())
protected

Call from onInit to create the developer HUD.

Parameters
sceneMay be NULL.
virtual shared_ptr<Camera> G3D::GApp::debugCamera ( )
inlinevirtual

Exposes the debugging camera.

static shared_ptr<class Lighting> G3D::GApp::defaultLighting ( )
static

Creates a default lighting environment for demos, which uses the file

on the noonclouds/noonclouds_*.jpg textures.

The code that it uses is below. Note that this loads a cube map every time that it is invoked, so this should not be used within the rendering loop.

shared_ptr<Lighting> lighting = Lighting::create();
lighting->shadowedLightArray.append(Light::directional(Vector3(1,2,1), Color3::fromARGB(0xfcf6eb)));
lighting->lightArray.append(Light::directional(Vector3(-1,-0.5f,-1), Color3::fromARGB(0x1e324d)));
lighting->environmentMap =
Texture::fromFile(pathConcat(System::findDataFile("sky"), "noonclouds/noonclouds_*.jpg"),
lighting->environmentMapColor = Color3::one();
RealTime G3D::GApp::desiredFrameDuration ( ) const
inline
float G3D::GApp::desiredFrameRate ( ) const
inline
void G3D::GApp::drawDebugShapes ( )

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
void G3D::GApp::drawMessage ( const std::string message)

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

Useful for loading screens and other slow operations.

const Stopwatch& G3D::GApp::graphicsWatch ( ) const
inline
virtual void G3D::GApp::loadScene ( const std::string sceneName)
inlinevirtual

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.

const Stopwatch& G3D::GApp::logicWatch ( ) const
inline
bool G3D::GApp::lowerFrameRateInBackground ( ) const
inline
const Stopwatch& G3D::GApp::networkWatch ( ) const
inline
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.

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.

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.

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

Unload/deallocate your data here.

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

virtual void G3D::GApp::onConsoleCommand ( const std::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 std::string& str) {
Add console processing here

        TextInput t(TextInput::FROM_STRING, str);
        if (t.isValid() && (t.peek().type() == Token::SYMBOL)) {
            std::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");
        }
        
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.

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.

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

Called from the default onGraphics.

Override and implement.

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

Called from the default onGraphics.

   Override and implement. 

The RenderDevice will already be cleared and the default camera set when this method is invoked.
By default, the Film's Framebuffer is bound and the output will be gamma corrected
and bloomed.

A common task is rendering UniversalSurface%s with your own shader, which can be done by:
rd->pushState();
rd->setShader(myShader)
for (int s = 0; s < surface3D.size(); ++s) {
const UniversalSurface::Ref& surface = dynamic_pointer_cast<UniversalSurface>(surface3D[s]);
if (surface) {
const UniversalSurface::GPUGeom::Ref& geom = surface->gpuGeom();
const UniversalBSDF::Ref& bsdf = geom->material->bsdf();
rd->setObjectToWorldMatrix(surface->coordinateFrame());
myShader->args.set("lambertianConstant", bsdf->lambertian().constant());
myShader->args.set("lambertianMap", Texture::whiteIfNull(bsdf->lambertian().texture()));
...
rd->beginIndexedPrimitives();
{
rd->setNormalArray(geom->normal);
rd->setVertexArray(geom->vertex);
rd->setTexCoordArray(0, geom->texCoord0);
rd->sendIndices(geom->primitive, geom->index);
}
rd->endIndexedPrimitives();
}
}
rd->popState();
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.

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

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

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.

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

Override this with your simulation code.

Called from GApp::run.

Default implementation does nothing.

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.
virtual void G3D::GApp::onUserInput ( class UserInput userInput)
protectedvirtual

Routine for processing user input from the previous frame.

Default implementation does nothing.

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)

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

void G3D::GApp::removeAllDebugShapes ( )

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

See Also
debugDraw, Shape, DebugID, removeDebugShape, drawDebugShapes
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
virtual void G3D::GApp::removeWidget ( const Widget::Ref module)
virtual

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

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

G3D::Film post-processing is not applied to the resulting images.

Parameters
outputIf empty or the first element is NULL, this is set to a series of new 1024 x 1024 ImageFormat::RGB16F() textures. Otherwise, the provided elements are used. Textures are assumed to be square. The images are generated in G3D::CubeFace order.
cameraThe field of view is changed to 90 degrees and the view is rotated in 90 degree increments, but other parameters from this camera are used unmodifed. The app->defaultCamera is temporarily set to each face's camera as well, and then restored.
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()));
}
virtual void G3D::GApp::renderDebugInfo ( )
virtual

Called from GApplet::run immediately after doGraphics to render the debugging text.

Does nothing if debugMode is false. It is not usually necessary to override this method.

void G3D::GApp::resize ( int  w,
int  h 
)
protected

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)

int G3D::GApp::run ( )

Call this to run the app.

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

Save the current scene over the one on disk.

virtual void G3D::GApp::setActiveCamera ( const shared_ptr< Camera > &  camera)
virtual
void G3D::GApp::setCameraManipulator ( const Manipulator::Ref man)
inline

The manipulator that positions the debugCamera every frame.

By default, this is set to the debugController. This may be set to NULL to disable explicit camera positioning.

virtual void G3D::GApp::setDesiredFrameRate ( float  fps)
virtual

Change to invoke frame limiting via onWait.

Defaults to finf()

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

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

virtual void G3D::GApp::setLowerFramerateInBackground ( bool  s)
inlinevirtual

If true, the desired frame rate is ignored when the OSWindow does not have focus and the program switches to running 4fps.

virtual void G3D::GApp::setRealTime ( RealTime  r)
virtual
virtual void G3D::GApp::setSimTime ( SimTime  s)
virtual
virtual void G3D::GApp::setSimTimeStep ( float  s)
virtual
shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< Texture > &  t,
const std::string windowCaption = "" 
)

Displays the texture in a new GuiWindow.

shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< PixelTransferBuffer > &  t,
const std::string windowCaption = "" 
)
shared_ptr<GuiWindow> G3D::GApp::show ( const shared_ptr< Image > &  t,
const std::string windowCaption = "" 
)
SimTime G3D::GApp::simTime ( ) const
inline

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

Takes into account simTimeSpeed. Automatically incremented after ooSimulation.

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

Elapsed time per RENDERED frame for ideal simulation.

Set to 0 to pause simulation, 1/fps to match real-time. The actual sdt argument to onSimulation is simTimStep / m_renderPeriod.

const Stopwatch& G3D::GApp::simulationWatch ( ) const
inline
static void G3D::GApp::staticConsoleCallback ( const std::string command,
void me 
)
staticprotected
const Stopwatch& G3D::GApp::userInputWatch ( ) const
inline
void G3D::GApp::vscreenPrintf ( const char *  fmt,
va_list  argPtr 
)
const Stopwatch& G3D::GApp::waitWatch ( ) const
inline
OSWindow* G3D::GApp::window ( ) const
inline

Friends And Related Function Documentation

friend class DeveloperWindow
friend
friend class OSWindow
friend
friend class VideoRecordDialog
friend

Member Data Documentation

bool G3D::GApp::catchCommonExceptions

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

Default is true.

GConsoleRef G3D::GApp::console

Command console.

std::string G3D::GApp::dataDir

Initialized to GApp::Settings::dataDir, or if that is "<AUTO>", to System::demoFindData().

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.

shared_ptr<GFont> G3D::GApp::debugFont

NULL if not loaded.

GuiPane* G3D::GApp::debugPane

debugWindow->pane()

Array<DebugShape> G3D::GApp::debugShapeArray

Shapes to be rendered each frame.

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

Array<std::string> G3D::GApp::debugText
protected

Strings that have been printed with screenPrintf.

Protected by m_debugTextMutex.

GuiWindow::Ref G3D::GApp::debugWindow

Add your own debugging controls to this window.

DeveloperWindow::Ref 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 NULL.

Action G3D::GApp::escapeKeyAction

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

(default is true)

bool G3D::GApp::fastSwitchCamera

When true GKey::F2 keydown deactivates the camera and restores the mouse cursor.

(default is true). This works even if GApp::Settings::useDeveloperTools is false.

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

The currently selected camera.

Referenced by activeCamera().

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

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

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

Used to find the frame for defaultCamera.

Referenced by cameraManipulator(), and setCameraManipulator().

shared_ptr<Texture> G3D::GApp::m_colorBuffer0
protected

Always bound to m_frameBuffer FrameBuffer::COLOR0.

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

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(shared_ptr<Manipulator>());
m_widgetManager->remove(m_debugController);
m_debugController.reset();
Color4 G3D::GApp::m_debugTextColor
protected
GMutex G3D::GApp::m_debugTextMutex
protected
Color4 G3D::GApp::m_debugTextOutlineColor
protected
shared_ptr<Texture> G3D::GApp::m_depthBuffer
protected

Always bound to m_frameBuffer FrameBuffer::DEPTH.

If NULL, the preferred depth format may not be supported by a Texture. In that case, check m_depthRenderBuffer.

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

Always bound to m_frameBuffer FrameBuffer::DEPTH.

This is used if the preferred depth format is not supported for Textures.

bool G3D::GApp::m_endProgram
protected
int G3D::GApp::m_exitCode
protected
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.

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

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

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

NULL by default.

The DeveloperWindow assumes that this is the GBuffer to be visualized if it is non-NULL.

Stopwatch G3D::GApp::m_graphicsWatch
protected

Referenced by graphicsWatch().

DebugID G3D::GApp::m_lastDebugID

Last DebugShape::id issued.

RealTime G3D::GApp::m_lastFrameOverWait
protected

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

Stopwatch G3D::GApp::m_logicWatch
protected

Referenced by logicWatch().

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

Referenced by networkWatch().

Array<Surface2DRef> G3D::GApp::m_posed2D
protected
Array<shared_ptr<Surface> > G3D::GApp::m_posed3D
protected
Stopwatch G3D::GApp::m_poseWatch
protected
int G3D::GApp::m_renderPeriod
protected

onPose(), onGraphics(), and onWait() execute once ever m_renderPeriod simulation frames.

This allows UI/network/simulation to be clocked much faster than rendering to increase responsiveness.

Settings G3D::GApp::m_settings
protected

The original settings.

Stopwatch G3D::GApp::m_simulationWatch
protected

Referenced by simulationWatch().

Stopwatch G3D::GApp::m_userInputWatch
protected

Referenced by userInputWatch().

Stopwatch G3D::GApp::m_waitWatch
protected

Referenced by waitWatch().

shared_ptr<WidgetManager> G3D::GApp::m_widgetManager
protected
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* G3D::GApp::renderDevice
bool G3D::GApp::showDebugText

When true, debugPrintf prints to the screen.

(default is true)

bool G3D::GApp::showRenderingStats

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

UserInput* G3D::GApp::userInput

documentation generated on Sat Jan 12 2013 22:49:55 using doxygen 1.8.2