[osg-users] Colors on GL_LINES

Ravi Mathur ravidavi at utexas.edu
Sun Dec 23 14:13:34 PST 2018


Lighting is enabled, which is why the line darkens based on camera
position. Disable lighting on line_geometry. Search osg examples for
GL_LIGHTING to see how.

---
Ravi

Sent from my phone, please excuse my brevity.

On Sun, Dec 23, 2018, 4:46 PM Diego Mancilla <dmancillac at gmail.com wrote:

> Hello,
>
>  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?
>
>
>
> Code:
> 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()));
> line_geometry->setColorArray(color);
> line_geometry->setColorBinding(osg::Geometry::BIND_OVERALL);
> root->addDrawable(line_geometry);
>
>
>
> Thank you!
>
> Cheers,
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=75341#75341
>
>
>
>
>
> _______________________________________________
> 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/20181223/4fc5b77b/attachment.html>


More information about the osg-users mailing list