[osg-users] Colors on GL_LINES

Diego Mancilla dmancillac at gmail.com
Sun Dec 23 13:46:20 PST 2018


 I'm drawing some simple lines on osg. So far I have successfully draw the lines and set a single color for each of them... but when I rotate the view the color is shown only on one direction of the camera, for instance, if rotate on 180 degrees the view, all lines are shown in black (looking from "down")... how can I get that the color of the lines is correctly shown regardless of the position/orientation of the camera on the viewer?

osg::Geode * root = getRoot();
osg::Vec4Array * color = new osg::Vec4Array;
double r, g, b, a;
r = 1.0;
g = 0.0;
b = 0.0;
a = 1.0;
color->push_back(osg::Vec4d(r, g, b, a)); //single color 
osg::Vec3Array* osg_points = new osg::Vec3Array;
Here I fill the vertex array
osg::Geometry* line_geometry = new osg::Geometry;
line_geometry->setVertexArray(osg_points); //osg_points has the points of the lines
line_geometry->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP, 0, osg_points->size()));

Thank you!


Read this topic online here:

More information about the osg-users mailing list