Fixes for multipipe support.

Addition of FrameStatsHandler to osgproducer demo to add frame stats.
This commit is contained in:
Robert Osfield
2003-01-29 17:16:26 +00:00
parent cf1ff34d38
commit 6c4f2f5207
13 changed files with 222 additions and 61 deletions

View File

@@ -0,0 +1,141 @@
#ifndef FRAME_STATS_HANDLER
#include <stdio.h>
#include <GL/gl.h>
namespace Producer {
class FrameStatsHandler : public CameraGroup::StatsHandler, public Camera::Callback
{
public:
FrameStatsHandler()
{
_fs.resize(6);
_index = 0;
}
void setArraySize(unsigned int size) { _fs.resize(size); }
unsigned int getArraySize() { return _fs.size(); }
void operator() (const CameraGroup &cg )
{
_index = (_index + 1) % _fs.size();
_fs[_index] = cg.getFrameStats();
}
void operator() (const Camera &)
{
glViewport( 0, 0, 1280, 1024 );
// Set up the Orthographic view
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho( -.01, .128, 600.0, -10.0, -1.0, 1.0 );
glPushAttrib( GL_ENABLE_BIT );
glDisable( GL_LIGHTING );
glDisable( GL_DEPTH_TEST );
glEnable( GL_BLEND );
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
unsigned int lindex = (_index + 1) % _fs.size();
Camera::TimeStamp zero = _fs[lindex]._startOfFrame;
int i;
double x1, x2, y1, y2;
for( int frame = 0; frame < _fs.size(); frame++ )
{
CameraGroup::FrameStats fs = _fs[(lindex + frame) % _fs.size()];
y1 = 0.0;
y2 = y1 + 10;
x1 = fs._startOfUpdate - zero;
x2 = fs._endOfUpdate - zero;
glBegin( GL_QUADS );
// Draw Update length
glColor4f( 0.0, 1.0, 0.0, 0.5 );
glVertex2d( x1, y1);
glVertex2d( x2, y1);
glVertex2d( x2, y2);
glVertex2d( x1, y2);
for( i = 0; i < fs.getNumFrameTimeStampSets(); i++ )
{
Camera::FrameTimeStampSet fts = fs.getFrameTimeStampSet(i);
y1 += 13.0;
y2 = y1 + 10.0;
x1 = fts[Camera::BeginCull] - zero;
x2 = fts[Camera::EndCull] - zero;
glColor4f( 0.0, 0.0, 1.0, 0.5 );
glVertex2d( x1, y1);
glVertex2d( x2, y1);
glVertex2d( x2, y2);
glVertex2d( x1, y2);
x1 = fts[Camera::BeginDraw] - zero;
x2 = fts[Camera::EndDraw] - zero;
glColor4f( 1.0, 0.0, 0.0, 0.5 );
glVertex2d( x1, y1);
glVertex2d( x2, y1);
glVertex2d( x2, y2);
glVertex2d( x1, y2);
}
glEnd();
glBegin( GL_LINES );
glColor4f( 1, 1, 1, 0.5 );
glVertex2d( fs._startOfFrame - zero , 0.0 );
y1 = fs.getNumFrameTimeStampSets() * 13.0 + 10.0;
glVertex2d( fs._startOfFrame - zero, y1 );
y1 = 12.5;
for( i = 0; i < fs.getNumFrameTimeStampSets(); i++ )
{
y2 = y1 + 11;
Camera::FrameTimeStampSet fts = fs.getFrameTimeStampSet(i);
Camera::TimeStamp vsync = fts[Camera::Vsync];
double x1 = vsync - zero;
glColor4f( 1.0, 1.0, 0.0, 0.5 );
glVertex2d( x1, y1 );
glVertex2d( x1, y2 );
y1 += 13.0;
}
glEnd();
}
glBegin( GL_LINES );
glColor4f( 1, 1, 1, 0.5 );
for( i = 0; i < 128; i++ )
{
glVertex2d((GLdouble)i*.001, y1);
if( !(i%10) )
glVertex2d((GLdouble)i*.001, y1 - 5.0);
else if( !(i%5) )
glVertex2d((GLdouble)i*.001, y1 - 3.0);
else
glVertex2d((GLdouble)i*.001, y1 - 1.0);
}
glEnd();
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
glPopAttrib();
}
private:
std::vector <CameraGroup::FrameStats> _fs;
unsigned int _index;
};
}
#endif

View File

@@ -3,7 +3,6 @@ include $(TOPDIR)/Make/makedefs
CXXFILES =\
osgproducer_viewer.cpp\
# osgproducer_cameragroup.cpp\
LIBS += -losgProducer -lProducer $(OSG_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
@@ -13,8 +12,8 @@ INSTFILES = \
EXEC = osgproducer
CXXFLAGS += $(OSG_INCLUDE_DIR)
LDFLAGS += $(OSG_LIB_DIR)
CXXFLAGS += $(PRODUCER_INCLUDE_DIR)
LDFLAGS += $(PRODUCER_LIB_DIR)
include $(TOPDIR)/Make/makerules

View File

@@ -2,12 +2,14 @@ TOPDIR = ../..
include $(TOPDIR)/Make/makedefs
CXXFILES =\
ProducerEventAdapter.cpp\
osgproducer.cpp\
osgproducer_viewer.cpp\
LIBS += -lProducer $(OSG_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
LIBS += -losgProducer -lProducer $(OSG_LIBS) $(GL_LIBS) $(X_LIBS) $(OTHER_LIBS)
EXEC = osgproducer
CXXFLAGS += $(PRODUCER_INCLUDE_DIR)
LDFLAGS += $(PRODUCER_LIB_DIR)
include $(TOPDIR)/Make/makerules

View File

@@ -11,6 +11,9 @@
#include <osgProducer/Viewer>
#include "FrameStatsHandler"
int main( int argc, char **argv )
{
@@ -62,6 +65,13 @@ int main( int argc, char **argv )
// set up the value with sensible defaults.
viewer->setUpViewer();
viewer->enableInstrumentation();
Producer::FrameStatsHandler* fsh = new Producer::FrameStatsHandler;
viewer->setStatsHandler(fsh);
viewer->getCamera(0)->addPostDrawCallback(fsh);
if( !pathfile.empty() ) {
osg::ref_ptr<osgGA::AnimationPathManipulator> apm = new osgGA::AnimationPathManipulator(pathfile);
if( apm.valid() && apm->valid() )

View File

@@ -1,11 +1,12 @@
//#define SINGLE_PIPE
#define ASSYMETRICAL_FRUSTUM
Camera "Camera 1"
{
RenderSurface "Window 1"
{
Visual { SetSimple };
Visual { SetSimple };
#ifdef SINGLE_PIPE
Screen 0;
WindowRectangle 0 0 426 512;
@@ -32,7 +33,7 @@ Camera "Camera 2"
{
RenderSurface "Window 2"
{
Visual { SetSimple };
Visual { SetSimple };
Screen 0;
#ifdef SINGLE_PIPE
WindowRectangle 426 0 426 512;
@@ -48,7 +49,7 @@ Camera "Camera 3"
{
RenderSurface "Window 3"
{
Visual { SetSimple };
Visual { SetSimple };
#ifdef SINGLE_PIPE
Screen 0;
WindowRectangle 852 0 426 512;