Hi Robert,

Thanks for this change.  Unfortunately it does not look like it fixes my issue.

I'm building GL3 core profile mode against OpenSceneGraph-3.6.  I use the 
main.cpp and CMakeLists.txt from my 6/1/18 email.  I'm using NVidia card with 
NVS 510, driver 388.19, OpenGL version 3.3.0 (due to core profile flag).  It is 
Windows 10.

I still see the error:
Warning: detected OpenGL error `invalid operation` at after 
drawable.compileGLObjects() call in GLObjectsVisitor::apply(osg::Drawable& 
drawable)

I have no modifications to OSG.  I did a full rebuild from scratch on OSG.


> What I believe is the problem is that the the VertexArrayState object
> gets initialized by the realizer operation and uses the
> State::getUseVertexAttributeAliasing() that was current at the time of
> the realizer operation, then code then calls
> State::setUseVertexAttributeAliasing() afterwards to a different
> value, so the rest of the OSG assumes that is now the current value
> but the global VertexArrayState is still set up against the original
> value so is passing using GL vertex array settings that are
> inconsistent with the shaders.

This is the second email you've mentioned the realizer operation.  I do not 
understand what you're referring to; this is very likely my inexperience with 
the depth of OSG.  Do you mean the code that eventually calls and includes 
Geometry::drawVertexArraysImplementation()?

I do not see any code that calls State::setUseVertexAttributeAliasing() in 
osg/src/*/*, or in osg/include/*/*.  I don't call it in main.cpp either (and if 
I did, I would only call it at startup, not on each geometry creation).

Are we running the same main.cpp?  I'm attaching my original just in case.

Thanks,

 - Dan



> -----Original Message-----
> From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On
> Behalf Of Robert Osfield
> Sent: Wednesday, June 13, 2018 7:45 AM
> To: OpenSceneGraph Users
> Subject: Re: [osg-users] VBO Bug with 3.6.1 and Normal Arrays
> 
> Hi Dan et. al,
> 
> I have had another look into this issue, looked at Dan's workaround
> and used Dan's test example to see investigate what might be going on.
> I have checked in a fix:
> 
> 
> https://github.com/openscenegraph/OpenSceneGraph/commit/673292b995
> 115c6ca9a3cc82c26e05023f504774
> 
> This allows the test example to work correctly in all different
> combinations with the realizer operation on/off etc.
> 
> What I believe is the problem is that the the VertexArrayState object
> gets initialized by the realizer operation and uses the
> State::getUseVertexAttributeAliasing() that was current at the time of
> the realizer operation, then code then calls
> State::setUseVertexAttributeAliasing() afterwards to a different
> value, so the rest of the OSG assumes that is now the current value
> but the global VertexArrayState is still set up against the original
> value so is passing using GL vertex array settings that are
> inconsistent with the shaders.
> 
> The solution is simple reassign the VertexArrayState for each call to
> State::setUseVertexAttributeAliasing().
> 
> I have only tested with Dan's test program, there is chance that other
> usage cases might tease out the issue in a different way, fingers
> crossed the just solves all these issue.
> 
> Could users who've seen issues with the arrays being used correctly
> update to the head of the OpenSceneGraph-3.6 branch and let me know
> how you get on.
> 
> If this all works fine then we can start looking at a release of 3.6.2
> this month.
> 
> Cheers,
> Robert.
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
#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();
}
cmake_minimum_required(VERSION 2.6)

SET(PROJECT_NAME arraybug)

PROJECT(${PROJECT_NAME})

FIND_PACKAGE(OpenThreads)
FIND_PACKAGE(osg)
FIND_PACKAGE(osgDB)
FIND_PACKAGE(osgUtil)
FIND_PACKAGE(osgGA)
FIND_PACKAGE(osgViewer)
FIND_PACKAGE(osgText)

SET(SOURCES
    main.cpp
)

INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR} ${OSG_INCLUDE_DIR})

LINK_DIRECTORIES(${OSG_LIB_DIR})

ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})

TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${OSG_LIBRARIES} ${OSGVIEWER_LIBRARIES} 
${OSGUTIL_LIBRARIES} ${OSGDB_LIBRARIES} ${OSGGA_LIBRARIES} ${OSGTEXT_LIBRARIES} 
${OPENTHREADS_LIBRARIES})
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to