QVR 4.1.0
A library to build Virtual Reality applications
Loading...
Searching...
No Matches
QVRApp Class Referenceabstract

QVR application interface. More...

#include <app.hpp>

Public Member Functions

virtual void render (QVRWindow *w, const QVRRenderContext &context, const unsigned int *textures)=0
 Render the current frame.
 
virtual void update (const QList< QVRObserver * > &observers)
 Update scene state.
 
virtual void getNearFar (float &nearPlane, float &farPlane)
 Set the near and far clipping plane.
 
virtual bool wantExit ()
 Indicate if the application wants to exit.
 
virtual bool initProcess (QVRProcess *p)
 Initialize an appplication process.
 
virtual void exitProcess (QVRProcess *p)
 Cleanup an application process before exiting.
 
virtual void preRenderProcess (QVRProcess *p)
 Perform actions once before each frame on each process.
 
virtual void postRenderProcess (QVRProcess *p)
 Perform actions once after each frame on each process.
 
virtual bool initWindow (QVRWindow *w)
 Initialize a window.
 
virtual void exitWindow (QVRWindow *w)
 Cleanup a window before exiting.
 
virtual void preRenderWindow (QVRWindow *w)
 Perform actions once before each frame on each window.
 
virtual void postRenderWindow (QVRWindow *w)
 Perform actions once after each frame on each window.
 
virtual void serializeDynamicData (QDataStream &ds) const
 Serialize data that changes between frames.
 
virtual void deserializeDynamicData (QDataStream &ds)
 Deserialize data that changes between frames.
 
virtual void serializeStaticData (QDataStream &ds) const
 Serialize data that does not change after initialization.
 
virtual void deserializeStaticData (QDataStream &ds)
 Deserialize data that does not change after initialization.
 
virtual void keyPressEvent (const QVRRenderContext &context, QKeyEvent *event)
 Handle a key press event.
 
virtual void keyReleaseEvent (const QVRRenderContext &context, QKeyEvent *event)
 Handle a key release event.
 
virtual void mouseMoveEvent (const QVRRenderContext &context, QMouseEvent *event)
 Handle a mouse move release event.
 
virtual void mousePressEvent (const QVRRenderContext &context, QMouseEvent *event)
 Handle a mouse press event.
 
virtual void mouseReleaseEvent (const QVRRenderContext &context, QMouseEvent *event)
 Handle a mouse release event.
 
virtual void mouseDoubleClickEvent (const QVRRenderContext &context, QMouseEvent *event)
 Handle a mouse double click event.
 
virtual void wheelEvent (const QVRRenderContext &context, QWheelEvent *event)
 Handle a wheel event.
 
virtual void deviceButtonPressEvent (QVRDeviceEvent *event)
 Handle a device button press event.
 
virtual void deviceButtonReleaseEvent (QVRDeviceEvent *event)
 Handle a device button release event.
 
virtual void deviceAnalogChangeEvent (QVRDeviceEvent *event)
 Handle a device analog element change event.
 

Detailed Description

QVR application interface.

This is the central interface that VR applications must implement. Most functions provide a default implementation. The only function that must be implemented is render().

Overview:

A key concept of QVR is that an application uses only one OpenGL context. This context is available to almost all functions in the interface.

Member Function Documentation

◆ deserializeDynamicData()

virtual void QVRApp::deserializeDynamicData ( QDataStream & ds)
inlinevirtual

Deserialize data that changes between frames.

Parameters
dsStream to read the serialization data from.

Implement this if you want to support multi-process configurations. Only serialize data that is required by render() and may change; this is typically what you manipulate in update().

See also serializeDynamicData().

◆ deserializeStaticData()

virtual void QVRApp::deserializeStaticData ( QDataStream & ds)
inlinevirtual

Deserialize data that does not change after initialization.

Parameters
dsStream to read the serialization data from.

Only implement this if you want to support multi-process configurations and your application benefits from transferring initialized data to child processes instead of initializing the data in each process.

See also serializeStaticData().

◆ deviceAnalogChangeEvent()

virtual void QVRApp::deviceAnalogChangeEvent ( QVRDeviceEvent * event)
inlinevirtual

Handle a device analog element change event.

Parameters
eventThe event

All events from all devices are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ deviceButtonPressEvent()

virtual void QVRApp::deviceButtonPressEvent ( QVRDeviceEvent * event)
inlinevirtual

Handle a device button press event.

Parameters
eventThe event

All events from all devices are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ deviceButtonReleaseEvent()

virtual void QVRApp::deviceButtonReleaseEvent ( QVRDeviceEvent * event)
inlinevirtual

Handle a device button release event.

Parameters
eventThe event

All events from all devices are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ exitProcess()

virtual void QVRApp::exitProcess ( QVRProcess * p)
inlinevirtual

Cleanup an application process before exiting.

Parameters
pThe process

This function cleans up process-specific data.

It is called by QVRManager when the application is terminated.

Called once per process at termination time.

◆ exitWindow()

virtual void QVRApp::exitWindow ( QVRWindow * w)
inlinevirtual

Cleanup a window before exiting.

Parameters
wThe window

This function cleans up window-specific data (this is usually unnecessary).

It is called by QVRManager when the application is terminated.

Called once per window at termination time.

◆ getNearFar()

virtual void QVRApp::getNearFar ( float & nearPlane,
float & farPlane )
inlinevirtual

Set the near and far clipping plane.

Parameters
nearPlaneNear clipping plane
farPlaneFar clipping plane

Called once before each frame on the main process.

◆ initProcess()

virtual bool QVRApp::initProcess ( QVRProcess * p)
inlinevirtual

Initialize an appplication process.

Parameters
pThe process

This function typically sets up process-specific data for rendering, e.g. OpenGL textures and vertex array buffers.

This function is called from QVRManager::init(). If it returns false, then QVRManager initialization will fail.

Called once per process at initialization time.

◆ initWindow()

virtual bool QVRApp::initWindow ( QVRWindow * w)
inlinevirtual

Initialize a window.

Parameters
wThe window

This function may set up window-specific data. This is usually unnecessary.

This function is called from QVRManager::init(). If it returns false, then QVRManager initialization will fail.

Called once per window at initialization time.

◆ keyPressEvent()

virtual void QVRApp::keyPressEvent ( const QVRRenderContext & context,
QKeyEvent * event )
inlinevirtual

Handle a key press event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once before each frame on the main process, before update().

◆ keyReleaseEvent()

virtual void QVRApp::keyReleaseEvent ( const QVRRenderContext & context,
QKeyEvent * event )
inlinevirtual

Handle a key release event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ mouseDoubleClickEvent()

virtual void QVRApp::mouseDoubleClickEvent ( const QVRRenderContext & context,
QMouseEvent * event )
inlinevirtual

Handle a mouse double click event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ mouseMoveEvent()

virtual void QVRApp::mouseMoveEvent ( const QVRRenderContext & context,
QMouseEvent * event )
inlinevirtual

Handle a mouse move release event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ mousePressEvent()

virtual void QVRApp::mousePressEvent ( const QVRRenderContext & context,
QMouseEvent * event )
inlinevirtual

Handle a mouse press event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ mouseReleaseEvent()

virtual void QVRApp::mouseReleaseEvent ( const QVRRenderContext & context,
QMouseEvent * event )
inlinevirtual

Handle a mouse release event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().

◆ postRenderProcess()

virtual void QVRApp::postRenderProcess ( QVRProcess * p)
inlinevirtual

Perform actions once after each frame on each process.

Parameters
pThe process

This function is called once for each process after each frame.

◆ postRenderWindow()

virtual void QVRApp::postRenderWindow ( QVRWindow * w)
inlinevirtual

Perform actions once after each frame on each window.

Parameters
wThe window

This function is called once for each window after each frame.

◆ preRenderProcess()

virtual void QVRApp::preRenderProcess ( QVRProcess * p)
inlinevirtual

Perform actions once before each frame on each process.

Parameters
pThe process

This function is called once for each process before each frame.

◆ preRenderWindow()

virtual void QVRApp::preRenderWindow ( QVRWindow * w)
inlinevirtual

Perform actions once before each frame on each window.

Parameters
wThe window

This function is called once for each window before each frame.

◆ render()

virtual void QVRApp::render ( QVRWindow * w,
const QVRRenderContext & context,
const unsigned int * textures )
pure virtual

Render the current frame.

Parameters
wThe window
contextThe render context with information on how to render
texturesThe textures to render into

This function is called for each window to render the current frame into textures. Monoscopic windows require one view per frame (for a single eye), and stereoscopic windows require two views (one for each eye). The context provides information about the required views and how to render them.

A typical implementation does the following:

for (int view = 0; view < context.viewCount(); view++) {
setup_framebuffer_object(textures[view], context.textureSize(view));
QMatrix4x4 projMatrix = context.frustum(view).toMatrix4x4();
QMatrix4x4 viewMatrix = context.viewMatrix(view);
set_and_clear_viewport(...);
render_my_scene(...);
}

This example renders one or two views sequentially. As an alternative, some platform-dependent OpenGL extensions allow to render two views at once to reduce rendering costs.

◆ serializeDynamicData()

virtual void QVRApp::serializeDynamicData ( QDataStream & ds) const
inlinevirtual

Serialize data that changes between frames.

Parameters
dsStream to write the serialization data to.

Implement this if you want to support multi-process configurations. Only serialize data that is required by render() and may change; this is typically what you manipulate in update().

See also deserializeDynamicData().

◆ serializeStaticData()

virtual void QVRApp::serializeStaticData ( QDataStream & ds) const
inlinevirtual

Serialize data that does not change after initialization.

Parameters
dsStream to write the serialization data to.

Only implement this if you want to support multi-process configurations and your application benefits from transferring initialized data to child processes instead of initializing the data in each process.

See also deserializeStaticData().

◆ update()

virtual void QVRApp::update ( const QList< QVRObserver * > & observers)
inlinevirtual

Update scene state.

Parameters
observersA list of observers that the application may modify.

Update scene state, e.g. for animations and interaction.

You can query the state of interaction devices via QVRManager::deviceCount() and QVRManager::device(). This is useful for implementing interaction, tracking, and navigation functionality (all optional).

The list of observers contains all observers in the active configuration. You can update these observers to implement your own tracking and/or navigation functionality (optional). You should only update an observer's navigation information via QVRObserver::setNavigation() if its navigation type is QVR_Navigation_Custom. You should only update an observer's tracking information via QVRObserver::setTracking() if its tracking type is QVR_Tracking_Custom.

Called once before each frame on the main process.

◆ wantExit()

virtual bool QVRApp::wantExit ( )
inlinevirtual

Indicate if the application wants to exit.

When this function returns true, the application will be terminated by the QVRManager. Typically an application returns true when ESC is pressed.

Called once before each frame on the main process.

◆ wheelEvent()

virtual void QVRApp::wheelEvent ( const QVRRenderContext & context,
QWheelEvent * event )
inlinevirtual

Handle a wheel event.

Parameters
contextThe context that this event originated from
eventThe event

All events from all windows on all processes are gathered by the QVRManager.

This function is called once for each event before each frame on the main process, before update().


The documentation for this class was generated from the following file: