[osg-users] Calling setUseVertexAttributeAliasing(true) after a viewer is being "run" causes a crasch

Anders Backman andersb at cs.umu.se
Wed Apr 7 05:33:23 PDT 2021


Hi all.
Just noticed that it is not possible to toggle the
setUseVertexAttributeAliasing after a viewer has been realized and
frame/run has been called and any text is involved in the scene. The
attached code is a modified osgViewer. If 's' (statistics) is shown after
the call to  setUseVertexAttributeAliasing, I get a callstack, meaning it
is not possible to toggle this feature while an application is being run.
Is that intentional?

I am running OSG 3.6.4 on Windows 10

>
osg160-osg.dll!osg::VertexArrayState::applyDisablingOfVertexAttributes(osg::State
& state) Line 294 C++

osg160-osg.dll!osg::Geometry::drawVertexArraysImplementation(osg::RenderInfo
& renderInfo) Line 989 C++
  osg160-osg.dll!osg::Geometry::drawImplementation(osg::RenderInfo &
renderInfo) Line 899 C++
  osg160-osg.dll!osg::Drawable::drawInner(osg::RenderInfo & renderInfo)
Line 277 C++
  osg160-osg.dll!osg::Drawable::draw(osg::RenderInfo & renderInfo) Line 619
C++
  osg160-osgUtil.dll!osgUtil::RenderLeaf::render(osg::RenderInfo &
renderInfo, osgUtil::RenderLeaf * previous) Line 84 C++
  osg160-osgUtil.dll!osgUtil::RenderBin::drawImplementation(osg::RenderInfo
& renderInfo, osgUtil::RenderLeaf * & previous) Line 488 C++

osg160-osgUtil.dll!osgUtil::RenderStage::drawImplementation(osg::RenderInfo
& renderInfo, osgUtil::RenderLeaf * & previous) Line 1408 C++
  osg160-osgUtil.dll!osgUtil::RenderBin::draw(osg::RenderInfo & renderInfo,
osgUtil::RenderLeaf * & previous) Line 432 C++
  osg160-osgUtil.dll!osgUtil::RenderStage::drawInner(osg::RenderInfo &
renderInfo, osgUtil::RenderLeaf * & previous, bool & doCopyTexture) Line
934 C++



-- 
__________________________________________
Anders Backman, HPC2N
90187 Umeå University, Sweden
anders at cs.umu.se http://www.hpc2n.umu.se
Cell: +46-70-392 64 67
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20210407/cb7a2a34/attachment.html>
-------------- next part --------------
/* OpenSceneGraph example, osgshape.
*
*  Permission is hereby granted, free of charge, to any person obtaining a copy
*  of this software and associated documentation files (the "Software"), to deal
*  in the Software without restriction, including without limitation the rights
*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*  copies of the Software, and to permit persons to whom the Software is
*  furnished to do so, subject to the following conditions:
*
*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*  THE SOFTWARE.
*/

#include <osg/Geode>
#include <osg/ShapeDrawable>
#include <osg/Material>
#include <osg/Texture2D>
#include <osgUtil/ShaderGen>

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgGA/StateSetManipulator>
#include <osgGA/TrackballManipulator>

#include <osgDB/ReadFile>
#include <osgDB/WriteFile>

#include <osg/Math>

// for the grid data..

osg::Geode* createShapes(osg::ArgumentParser& arguments)
{
  osg::Geode* geode = new osg::Geode();

  float radius = 0.8f;
  float height = 1.0f;

  osg::TessellationHints* hints = new osg::TessellationHints;
  hints->setDetailRatio(0.5f);

  geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), radius), hints));
  geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(2.0f, 0.0f, 0.0f), 2 * radius), hints));
  geode->addDrawable(new osg::ShapeDrawable(new osg::Cone(osg::Vec3(4.0f, 0.0f, 0.0f), radius, height), hints));
  geode->addDrawable(new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(6.0f, 0.0f, 0.0f), radius, height), hints));
  geode->addDrawable(new osg::ShapeDrawable(new osg::Capsule(osg::Vec3(8.0f, 0.0f, 0.0f), radius, height), hints));



  return geode;
}

int main(int argc, char** argv)
{
  osg::ArgumentParser arguments(&argc, argv);

  // construct the viewer.
  osgViewer::Viewer viewer(arguments);

  // add model to viewer.
  viewer.setSceneData(createShapes(arguments));

  // add the state manipulator
  viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
  viewer.addEventHandler(new osgViewer::StatsHandler);

  viewer.setCameraManipulator(new osgGA::TrackballManipulator());

  viewer.realize();
  int i = 0;
  while (!viewer.done()) {
    i++;
    if (i == 2000)
    {
      osgViewer::Viewer::Windows windows;
      viewer.getWindows(windows);

      for (osgViewer::Viewer::Windows::iterator itr = windows.begin(); itr != windows.end(); ++itr)
      {
        osg::State* s = (*itr)->getState();
        s->setUseModelViewAndProjectionUniforms(true);
        s->setUseVertexAttributeAliasing(true);
      }

    }
    viewer.frame();
  }

}


More information about the osg-users mailing list