void DisplayRequirementsVisitor::applyStateSet(StateSet& stateset)
{
    if (!_ds) _ds = new osg::DisplaySettings;

   unsigned int min = 0; // assume stencil not needed by this stateset.
   
   if (stateset.getMode(GL_STENCIL_TEST) & StateAttribute::ON)
   {
        min = 1; // number stencil bits we need at least.
   }

   if (stateset.getAttribute(StateAttribute::STENCIL))
   {
        min = 1; // number stencil bits we need at least.
   }
   
   if (min>_ds->getMinimumNumStencilBits())
   {
        // only update if new minimum exceeds previous minimum.
        _ds->setMinimumNumStencilBits(min);
   }    
}