pfViewerManager(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
NAMEpfViewerManager - Manage pfViewers and application
FUNCTION SPECIFICATION
#include <Performer/pfx/pfViewerManager.h>
static void pfViewerManager::init(int argc, char **argv);
static pfType* pfViewerManager::getClassType(void);
static void pfViewerManager::config();
static void pfViewerManager::config(int arg, ...);
static void pfViewerManager::setExitFlag();
static void pfViewerManager::mainLoop();
static int pfViewerManager::getNumViewers();
static int pfViewerManager::removeViewer(pfViewer* viewer);
static pfViewer* pfViewerManager::getViewer(int i = 0);
static int pfViewerManager::forkedGUI();
static int pfViewerManager::getArgc();
static char** pfViewerManager::getArgv();
static void pfViewerManager::setPostFrameFuncPtr(funcPtr* f,
void* data);
static funcPtr* pfViewerManager::getPostFrameFuncPtr(void** data);
static void pfViewerManager::setPostSyncFuncPtr(funcPtr* f,
void* data);
static funcPtr* pfViewerManager::getPostSyncFuncPtr(void** data);
static void -
pfViewerManager::setReturnValueForCallbacks(int value);
static int pfViewerManager::getWinMode();
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfViewerManager is derived from the parent
class pfObject, so each of these member functions of class pfObject are
also directly usable with objects of class pfViewerManager. This is also
true for ancestor classes of class pfObject.
Page 1
pfViewerManager(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfViewerManager can also be used with these
functions designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
The pfViewerManager class provides the infrastructure for designing
applications which use the new pfViewer classes. By doing so, it replaces
the traditional OpenGL Performer main loop with a more object oriented
approach (see pfViewerManager::mainLoop() below.) It also changes some of
the more traditional methods of developing applications such as using
channel draw callbacks by demonstrating how to derive specialized classes
to perform such operations instead.
Some of the main OpenGL Performer functions which should not get invoked
directly due to this new interface include:
pfFrame(),
pfSync(),
pfConfig()
Both pfFrame() and pfSync() are encapsulated within
pfViewerManager::mainLoop().
Page 2
pfViewerManager(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
The simplest OpenGL Performer program based on this new architecture
would thus look like:
int main(int argc,char **argv)
{
pfViewerManager::init(argc,argv);
pfViewerManager::config();
pfMotifViewer *viewer = new pfMotifViewer();
if(argv[1])
viewer->loadModel(argv[1]);
pfViewerManager::mainLoop();
}
Any functions which typically get called between pfInit() and pfConfig()
(including pfMultiprocess().) are still valid. The difference here is
that those calls must go between pfViewerManager::init() and
pfViewerManager::config().
The method pfViewerManager::config() has two incarnations. The first,
which accepts no arguments basically just calls pfConfig() without
performing any other additional operations.
The second incarnation of this method is a variable argument version of
this method which accepts several different value/tokens and must be NULL
terminated. The following is a list of the tokens that are supported by
this method:
PFVMAN_FRAME_RATE this followed by a double value will set
the frame rate to use when calling
pfFrameRate().
PFVMAN_PHASE set phase to use via pfPhase().
PFVMAN_FORK_GUI specify bool to determine wether or not to
fork draw process when using a viewer that
derives from pfGUIViewer.
PFVMAN_EVENT_SAMPLING specify filename to use for use with OpenGL
Performer real-time event generator/viewer
(see evpp(1).)
PFVMAN_RUN_TIME specify run time for program if not until
other trigger for exit occurs beforehand.
Page 3
pfViewerManager(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
PFVMAN_WIN_MODE specify attributes to be used when create
pipe windows associated with all pfViewers
in application.
The pfViewerManager::setExitFlag() method, when envoked will cause the
program to exit, ensuring that pfExit() is called but only after doing
things such as writing the event samples from evpp(1) to disk, if
appropriate. This is the preffered method for exiting applications and
pfExit() should not be used in conjunction with applications based on
this framework.
The pfViewerManager::mainLoop() method causes the main application loop
to start executing. This loop looks something like this:
while(1) {
pfSync();
// invoke post sync function callbacks, if any
pfFrame();
// invoke post frame function callbacks, if any
}
In addition, new view information (if any) is processed and several other
tasks are performed that involve ensuring that the channels associated
with the pfViewers involved in the simulation reflect the current state
of the sytem.
The pfViewerManager::getNumViewers() method returns the number pfViewers
currently being managed by the system. In order to delete a pfViewer, one
should invoke the method pfViewer::removeViewer() which takes care of
this task in addition to ensuring that it is removed from the list of
viewers which are being managed by the pfViewerManager.
The pfViewerManager::getViewer(int i=0) method returns a pointer two the
i'th pfViewer that is managed by the pfViewerManager.
The pfViewerManager::forkedGUI() method returns 0 or 1 depending on
wether or not the draw process was forked via PFVMAN_FORK_GUI. By default
this is false.
The pfViewerManager::init() method is atypical and requires to arguments
that correspond to argc and argv from main(). It initializes the class
and calls pfInit(). One may retrieve the values used to call this method
via pfViewerManager::getArgc() and pfViewerManager::getArgv().
The pfViewerManager::setPostFrameFuncPtr() function allows one to specify
a function pointer along with some user data that will get called
directly after the main loop calls pfFrame(). The same reasonning applies
to pfViewerManager::setPostSyncFuncPtr() which gets called directly after
pfSync(). Note that in both cases, these functions will be called once
Page 4
pfViewerManager(3pf) OpenGL Performer 3.2.2 libpfx C++ Reference Pages
for each viewer that is managed by the pfViewerManager.
The declaration for the function pointer that may be passed to these
methods is:
typedef void (funcPtr)(pfViewer *viewer,void *data);
One can retrieve the values of both the user data and the function
pointers currently set via pfViewerManager::getPost(Frame|Sync)Ptr().
The pfViewerManager::getWinMode() returns the value associated with the
call to pfViewerManager::config() and the parameter PFVMAN_WIN_MODE.
NOTES
The libpfx source code, object code and documentation are provided as
unsupported software. Routines are subject to change in future releases.
The most recent version of this software may be found at the following
URL: http://oss.sgi.com/projects/performer/.
SEE ALSO
pfViewer, pfGUIViewer, pfMotifViewer
Page 5