[osg-users] Limit in size of VBOs?

Antoine Rennuit antoinerennuit at hotmail.com
Wed Sep 6 01:49:37 PDT 2017


Dear OSG forum,

I am currently switching from using display lists to using VBOs.

I display 2 different meshes with it:

	 one is a usual mesh with ~1000 triangles

	 the other one is very dense ~10M vertices (from a room scan)



The usual mesh displays fine with the VBOs, but when adding the dense mesh I have a crash in the rendering, here is my calls stack:

[img]https://drive.google.com/open?id=0B4i1g-UqIF8yZFk4TlRrblVrUVk[/img]

As you can see, it is really at the rendering stage that the problem happens, not when setting up the VBO.

Here is my code


Code:

osg::ref_ptr<osg::Geode> SetupMesh(const Eigen::Vector3Array& vertices, IntegerArray const& triangles, const Eigen::Vector3Array& normals, const osg::Vec4f& color, Node* node)
{
    osg::ref_ptr<osg::Geode> geode = new osg::Geode();
    assert(geode);
    osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry();
    assert(geometry);
    osg::ref_ptr<osg::Vec3Array> vertices_osg = new osg::Vec3Array();
    assert(vertices_osg);
    osg::ref_ptr<osg::Vec3Array> normals_osg = new osg::Vec3Array();
    assert(normals_osg);
    osg::ref_ptr<osg::DrawElementsUInt> triangles_osg = new osg::DrawElementsUInt(osg::PrimitiveSet::TRIANGLES, 0);
    assert(triangles_osg);
    osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array();
    assert(colors);

    osg::ref_ptr<NodeReference> userData = new NodeReference(node);
    geometry->setUserData(userData);

    // VBO.
//    geometry->setUseDisplayList(false);
    geometry->setUseVertexBufferObjects(true);

    // Setup.
    geode->addDrawable(geometry);
    geometry->setVertexArray(vertices_osg);
    geometry->setNormalArray(normals_osg);
    geometry->addPrimitiveSet(triangles_osg);
    geometry->setColorArray(colors);

    // Vertices.
    vertices_osg->reserve(vertices.size());
    for (int i = 0; i < vertices.size(); ++i)
        vertices_osg->push_back(EigenToOsgVector3(vertices[i]));

    // Normals.
    normals_osg->setBinding(osg::Array::BIND_PER_VERTEX);

    normals_osg->reserve(normals.size());
    for (int i = 0; i < normals.size(); ++i)
        normals_osg->push_back(EigenToOsgVector3(normals[i]));

    // Triangles.
    triangles_osg->reserve(triangles.size());
    for (int i = 0; i < triangles.size(); ++i)
        triangles_osg->push_back(triangles[i]);

    // Colors.
    colors->setBinding(osg::Array::BIND_OVERALL);

    colors->push_back(color);

    return geode;
}




Any idea of what's going on?

Thanks,

Antoine[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71638#71638







More information about the osg-users mailing list