From Paul Martz, added --points option for forcing points rendering of polygonal models

This commit is contained in:
Robert Osfield 2009-01-05 17:06:09 +00:00
parent 85fffc2e76
commit 910927145e

View File

@ -24,6 +24,7 @@
#include <osg/BlendFunc>
#include <osg/Texture2D>
#include <osg/PointSprite>
#include <osg/PolygonMode>
#include <iostream>
@ -115,6 +116,7 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
arguments.getApplicationUsage()->addCommandLineOption("--sprites","Point sprites.");
arguments.getApplicationUsage()->addCommandLineOption("--points","Sets the polygon mode to GL_POINT for front and back faces.");
// construct the viewer.
@ -133,6 +135,9 @@ int main( int argc, char **argv )
bool usePointSprites = false;
while (arguments.read("--sprites")) { usePointSprites = true; };
bool forcePointMode = false;
while (arguments.read("--points")) { forcePointMode = true; };
if (arguments.argc()<=1)
{
arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
@ -158,10 +163,9 @@ int main( int argc, char **argv )
viewer.setSceneData(loadedModel.get());
osg::StateSet* stateset = loadedModel->getOrCreateStateSet();
if (usePointSprites)
{
osg::StateSet* stateset = loadedModel->getOrCreateStateSet();
/// Setup cool blending
osg::BlendFunc *fn = new osg::BlendFunc();
stateset->setAttributeAndModes(fn, osg::StateAttribute::ON);
@ -176,6 +180,14 @@ int main( int argc, char **argv )
stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON);
}
if( forcePointMode )
{
/// Set polygon mode to GL_POINT
osg::PolygonMode *pm = new osg::PolygonMode(
osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::POINT );
stateset->setAttributeAndModes( pm, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);
}
// register the handler for modifying the point size
viewer.addEventHandler(new KeyboardEventHandler(viewer.getCamera()->getOrCreateStateSet()));