Canvas troubleshooting: Difference between revisions

Jump to navigation Jump to search
m
Line 226: Line 226:
== Useful C++ changes ==
== Useful C++ changes ==
{{Note|The following patches are intended to help better understand what's going on behind the scenes. They are intended to be regularly rebased onto SG/FG 'next'. In the mid-term, our hope is to ensure that people working on Nasal/Canvas related features get a better understanding about when, where and why Canvas performance is affected.}}
{{Note|The following patches are intended to help better understand what's going on behind the scenes. They are intended to be regularly rebased onto SG/FG 'next'. In the mid-term, our hope is to ensure that people working on Nasal/Canvas related features get a better understanding about when, where and why Canvas performance is affected.}}


=== Adding support for wireframe mode ===
=== Adding support for wireframe mode ===
To enable wireframe mode, we only need to change the osg::StateSet accordingly. Internally, each Canvas element contains a <code>osg::MatrixTransform</code> node - there's a virtual method <code></code> exposed returning the StateSet, so that we can directly modify the stateset:
<syntaxhighlight lang="cpp">
osg::StateSet *state = getOrCreateStateSet();
osg::PolygonMode *polyModeObj;
polyModeObj = dynamic_cast< osg::PolygonMode* >
                            ( state->getAttribute( osg::StateAttribute::POLYGONMODE ));
if ( !polyModeObj ) {
    polyModeObj = new osg::PolygonMode;
    state->setAttribute( polyModeObj );   
  }
 
polyModeObj->setMode(  osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE );
</syntaxhighlight>
This change could be applied globally for each Canvas, or optionally per Canvas Element - the latter is more useful for troubleshooting things without affecting all active Canvas textures.
The corresponding diff for $SG_SRC adding this as a property-controlled option, looks like this:
<syntaxhighlight lang="diff">
<syntaxhighlight lang="diff">
</syntaxhighlight>
</syntaxhighlight>

Navigation menu