OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

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


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Blanky
Newbie


Joined: 26 Jun 2019
Posts: 2

PostPosted: Thu Jun 27, 2019 12:10 am    Post subject:
OpenGL Error 'invalid value' when using osg::LineWidth [SOLVED]
Reply with quote

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





SOLVED:

AHAH I somehow was setting the osg::LineWidth's width to 0 and apparently that was what was causing it. I somehow forgot to initialize some other member variable to be > 0.
Back to top
View user's profile Send private message
Voerman, L.
Guest





PostPosted: Thu Jun 27, 2019 7:31 am    Post subject:
OpenGL Error 'invalid value' when using osg::LineWidth
Reply with quote

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 < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
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:ShockedN);
m_glPointGeode->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute:ShockedN);

//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:ShockedN);
m_lineGeom->getOrCreateStateSet()->setAttributeAndModes(m_lineWidth, osg::StateAttribute::OVERRIDE | osg::StateAttribute:ShockedN | 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:ShockedN);
m_lineStripGeode->getOrCreateStateSet()->setMode(GL_LINE_SMOOTH, osg::StateAttribute:ShockedN);
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:ShockedN);
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:ShockedN | 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
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Shared openGL Context generating Glyp... pioupiou General 0 Fri Jul 19, 2019 3:23 pm View latest post
No new posts Particle message: ParticleProcessor &... Paradox General 0 Tue Jul 16, 2019 4:12 pm View latest post
No new posts Particle message: ParticleProcessor &... Paradox General 0 Tue Jul 16, 2019 4:00 pm View latest post
No new posts Particle message: ParticleProcessor &... Paradox General 0 Tue Jul 16, 2019 3:56 pm View latest post
No new posts Particle message: ParticleProcessor &... Paradox General 0 Tue Jul 16, 2019 3:56 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP