[osg-users] OpenGL Error 'invalid value' when using osg::LineWidth

Voerman, L. l.voerman at rug.nl
Thu Jun 27 00:30:24 PDT 2019


Hi Brett,
if getHandle()->getLineWidth() returns 0 or a negative value that would
explain all. Can you write out the problematic node to an osg file and see
if the invalid value error occurs in the osgviewer as well?
That would help to narrow down the options.
Laurens.

On Thu, Jun 27, 2019 at 2:19 AM Brett Sackstein <basackstein at hotmail.com>
wrote:

> Hello, I'm using osg and osgEarth to create a program. I try to draw a
> path that follows another node in the scene such that when I set its
> position, I add an additional GL_POINT vertex and a pair of LINE_STRIP
> vertices for a new anchor point for two geodes. However, I'm constantly
> being spammed in my application output with the invalid value error.
>
> I have been pulling my hair out because I spent hours figuring out which
> geometry was causing it. This is the format of my code upon construction:
>
>
> Code:
> PathNode::PathNode(IPathObject *pathObject, osgEarth::MapNode* mapNode) :
> CommonMapNode(pathObject, mapNode), osg::Group(), m_crossedDateLine(false),
> m_offset(0.0){
>
> m_lineColorArray = new osg::Vec4Array;
> m_glPointColorArray = new osg::Vec4Array;
>
> m_lineVertexArray = new osg::Vec3Array;
> m_glPointVertexArray = new osg::Vec3Array;
>
> m_lineGeom = new osg::Geometry;
> m_lineGeom->setUseDisplayList(false);
> m_lineGeom->setUseVertexArrayObject(true);
> m_lineGeom->setUseVertexBufferObjects(true);
> m_lineGeom->setDataVariance(osg::Object::DataVariance::DYNAMIC);
>
> m_glPointGeom = new osg::Geometry;
> m_glPointGeom->setUseDisplayList(false);
> m_glPointGeom->setUseVertexArrayObject(true);
> m_glPointGeom->setUseVertexBufferObjects(true);
> m_glPointGeom->setDataVariance(osg::Object::DataVariance::DYNAMIC);
>
> m_lineStripGeode = new osg::Geode;
> m_glPointGeode = new osg::Geode;
>
> m_lineStripGeode->getOrCreateStateSet()->setRenderBinDetails(0,
> "RenderBin", osg::StateSet::OVERRIDE_PROTECTED_RENDERBIN_DETAILS);
> m_glPointGeode->getOrCreateStateSet()->setRenderBinDetails(0, "RenderBin",
> osg::StateSet::OVERRIDE_PROTECTED_RENDERBIN_DETAILS);
>
> m_lineStripGeode->getOrCreateStateSet()->setMode(GL_BLEND,
> osg::StateAttribute::ON);
> m_glPointGeode->getOrCreateStateSet()->setMode(GL_BLEND,
> osg::StateAttribute::ON);
>
> //Line Geometry
> m_lineGeom->setVertexArray(m_lineVertexArray);
> m_lineGeom->setDataVariance(osg::Object::DataVariance::DYNAMIC);
> m_lineDrawArray = new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, 0,
> m_lineVertexArray->size());
> m_lineDrawArray->setDataVariance(osg::Object::DataVariance::DYNAMIC);
> m_lineGeom->addPrimitiveSet(m_lineDrawArray);
> m_lineWidth = new osg::LineWidth(getHandle()->getLineWidth());
> m_lineGeom->getOrCreateStateSet()->setMode(GL_LINE_SMOOTH,
> osg::StateAttribute::ON);
> m_lineGeom->getOrCreateStateSet()->setAttributeAndModes(m_lineWidth,
> osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON |
> osg::StateAttribute::PROTECTED);
> m_lineGeom->setColorArray(m_lineColorArray, osg::Array::BIND_PER_VERTEX);
>
> //Line Geode
> m_lineStripGeode->addDrawable(m_lineGeom);
> m_lineStripGeode->setDataVariance(osg::Object::DataVariance::DYNAMIC);
> m_lineStripGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,
> osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF |
> osg::StateAttribute::PROTECTED);
> m_lineStripGeode->getOrCreateStateSet()->setMode(GL_BLEND,
> osg::StateAttribute::ON);
> m_lineStripGeode->getOrCreateStateSet()->setMode(GL_LINE_SMOOTH,
> osg::StateAttribute::ON);
> m_lineStripGeode->addCullCallback(new osgEarth::HorizonCullCallback);
>
> //GL Point Geometry
> m_glPointGeom->setColorArray(m_glPointColorArray,
> osg::Array::BIND_OVERALL);
> m_glPointGeom->setVertexArray(m_glPointVertexArray);
>
> m_glPointsDrawArray = new osg::DrawArrays(osg::PrimitiveSet::POINTS, 0,
> m_glPointVertexArray->size());
> m_glPointGeom->addPrimitiveSet(m_glPointsDrawArray);
> m_glPointGeom->getOrCreateStateSet()->setMode(GL_LIGHTING,
> osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF |
> osg::StateAttribute::PROTECTED);
> osg::ref_ptr<osg::Point> pointAttributes = new osg::Point(5);
> m_glPointGeom->getOrCreateStateSet()->setAttributeAndModes(pointAttributes,
> osg::StateAttribute::ON);
> m_glPointGeom->setColorArray(m_glPointColorArray,
> osg::Array::BIND_PER_VERTEX);
>
> //GL Point Geode
> m_glPointGeode->addDrawable(m_glPointGeom);
>
> addChild(m_lineStripGeode);
> addChild(m_glPointGeode);
> }
>
>
>
>
> It turns out the lines:
>
>
> Code:
> m_lineWidth = new osg::LineWidth(getHandle()->getLineWidth());
> m_lineGeom->getOrCreateStateSet()->setAttributeAndModes(m_lineWidth,
> osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON |
> osg::StateAttribute::PROTECTED);
>
>
>
>
> Is what is causing this error to spam my output. Nothing visually seems
> incorrect. All colors and points are correct. Nothing is blinking or acting
> strange. What I don't understand with this "path" that I've created is that
> I actually have a "line" equivalent class that literally does the same
> thing, but with only 2 points and not 1 to n points and doesn't use
> GL_POINT at all for the end points.
>
> I figured out if I just don't add the osg::LineWidth to the m_lineGeom
> variable, then the error disappears, but I need the ability to set the
> line's width. Can anybody explain what may be causing this to print even
> though nothing about my lines look ill-formed? Thanks for any help.
>
> - Blanky
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=76334#76334
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190627/a35585b3/attachment.html>


More information about the osg-users mailing list