Changeset 9442

Show
Ignore:
Timestamp:
01/05/09 18:06:09 (4 years ago)
Author:
robert
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgpoints/osgpoints.cpp

    r7648 r9442  
    2525#include <osg/Texture2D> 
    2626#include <osg/PointSprite> 
     27#include <osg/PolygonMode> 
    2728 
    2829#include <iostream> 
     
    116117    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); 
    117118    arguments.getApplicationUsage()->addCommandLineOption("--sprites","Point sprites."); 
    118      
     119    arguments.getApplicationUsage()->addCommandLineOption("--points","Sets the polygon mode to GL_POINT for front and back faces."); 
     120 
    119121 
    120122    // construct the viewer. 
     
    133135    bool usePointSprites = false; 
    134136    while (arguments.read("--sprites")) { usePointSprites = true; }; 
     137 
     138    bool forcePointMode = false; 
     139    while (arguments.read("--points")) { forcePointMode = true; }; 
    135140 
    136141    if (arguments.argc()<=1) 
     
    159164     
    160165 
     166    osg::StateSet* stateset = loadedModel->getOrCreateStateSet(); 
    161167    if (usePointSprites)     
    162168    { 
    163         osg::StateSet* stateset = loadedModel->getOrCreateStateSet(); 
    164  
    165169        /// Setup cool blending 
    166170        osg::BlendFunc *fn = new osg::BlendFunc(); 
     
    175179        tex->setImage(osgDB::readImageFile("Images/particle.rgb")); 
    176180        stateset->setTextureAttributeAndModes(0, tex, osg::StateAttribute::ON); 
     181    } 
     182 
     183    if( forcePointMode ) 
     184    { 
     185        /// Set polygon mode to GL_POINT 
     186        osg::PolygonMode *pm = new osg::PolygonMode( 
     187            osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::POINT ); 
     188        stateset->setAttributeAndModes( pm, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); 
    177189    } 
    178190