Hi Dan,

On 1 June 2018 at 16:01, Daniel Emminizer, Code 5773
<dan.emmini...@nrl.navy.mil> wrote:
> Attached is a demo of the problem that generates a console warning.  More 
> complex scenes can cause crashes.  The red triangle has the problem, but the 
> green one does not.

I have built the example, and to help with test have changed the
#ifdef blocks to ones that check arguments.read("--ro") for the
RealizerOperation usage and "--reset" for the
resetVertexAttributeAlias.   Attached is the modified file.

If you run the test with --ro and have it use the custom
RealizerOperation I see a completely red cessna.  If I used --ro and
--reset I see multi-colour (blue, red etc) one, if I run without any
options I see the multi-colour one.

I don't see any command line warnings though.  I'm testing under
Kubuntu with OSG-3.6 branch, my drive info is:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 760/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 384.111
OpenGL core profile shading language version string: 4.50 NVIDIA

I don't yet have any idea what is going wrong, it's obviously very odd
that the custom RealizeOperation is having an effect when it does
nothing itself.

Before I start diving deeper I'd like to know what others are seeing
with these different combinations and if any errors are being printed
in the console, if so what are they.  Also let us know the OSG version
and driver/OS details.

Robert.
#include <osg/Geode>
#include <osg/Geometry>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>

osg::Node* createTriangle(float x, bool earlyBinding, const osg::Vec4f& color)
{
    osg::Geode* geode = new osg::Geode;
    osg::Geometry* geom = new osg::Geometry;
    geom->setUseVertexArrayObject(true);
    geom->setUseVertexBufferObjects(true);

    osg::Vec3Array* vertices = new osg::Vec3Array();
    vertices->push_back(osg::Vec3(x - 100, 0, -100));
    vertices->push_back(osg::Vec3(x, 0, 100));
    vertices->push_back(osg::Vec3(x, 0, -100));

    osg::Vec3Array* normals = new osg::Vec3Array;
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    normals->push_back(osg::Vec3(0, -1, 0));
    if (earlyBinding)
        normals->setBinding(osg::Array::BIND_PER_VERTEX);

    osg::Vec4Array* colors = new osg::Vec4Array(osg::Array::BIND_OVERALL);
    colors->push_back(color);

    geom->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES, 0, 3));
    geom->setVertexArray(vertices);
    geom->setNormalArray(normals);
    geom->setColorArray(colors);
    geode->addDrawable(geom);

    // Warning gets generated due to this line not causing (eventually) a VBO creation
    if (!earlyBinding)
        normals->setBinding(osg::Array::BIND_PER_VERTEX);
    return geode;
}

osg::Node* createScene()
{
    osg::Group* group = new osg::Group;

    // Reddish: Generates warning
    group->addChild(createTriangle(-100, false, osg::Vec4f(1, 0.5, 0.5, 1)));

    // Greenish: No warnings
    group->addChild(createTriangle(100, true, osg::Vec4f(0.5,1,0.5,1)));

    return group;
}

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

    // construct the viewer.
    osgViewer::Viewer viewer(arguments);
    viewer.setSceneData(createScene());
    viewer.setUpViewInWindow(100, 100, 800, 600);
    viewer.addEventHandler(new osgViewer::StatsHandler());

    return viewer.run();
}
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to