in OpenGL if GL_LIGHTING is disabled, the final color of polygon is determined by glColor.
If you see ShapeDrawable::drawImplemenation(), there is glColor call.
Code:
osg::State& state = *renderInfo.getState();
GLBeginEndAdapter& gl = state.getGLBeginEndAdapter();
if (_shape.valid())
{
gl.Color4fv(_color.ptr()); ///// <---------
DrawShapeVisitor dsv(state,_tessellationHints.get());
_shape->accept(dsv);
}
Cheers,
Filip[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=44181#44181
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Yes, which is what I wrote:
"What is the idea behind having a color in ShapeDrawable?"
I cant see any reason why there would be a color associated to a shape?Create a triangle, and by the way, its red. That was my question.
So if you WOULD like to control the color by disabling light and use diffuse, it will not work.It will be white (due to the call in ShapeDrawable).
Anyway, there are ways around this. I just thought it was very inconsistent to associate a color to a ShapeDrawable.
I don't understand what you mean here. If you disable lighting, material colors are irrelevant. The ShapeDrawable's colors are the ONLY way to set the color.
I'm not sure what's inconsistent about it. It behaves like any other OpenGL geometry.
As Filip indicated, the color only applies if lighting is disabled. When you disable lighting, no lighting calculations are done, and material colors become irrelevant, just as they do with any OpenGL rendering when lighting is disabled. Only the geometry color is used. If you want an unlit red cube, this is how you'd do it.
When lighting is enabled, the material can be set to either ignore the geometry colors:
material->setColorMode(osg::Material::OFF);
or to use the geometry colors as one of the material colors:
material->setColorMode(osg::Material::DIFFUSE); (for example)
It's your choice how you want to apply the material.
--"J"
Hi Jason,
On Fri, Dec 2, 2011 at 11:30 AM, Jason Daly <jd...@ist.ucf.edu> wrote:I don't understand what you mean here. If you disable lighting, material colors are irrelevant. The ShapeDrawable's colors are the ONLY way to set the color.
That's actually not the case with OSG. If you look at the source for osg::Material, you will notice it calls glColor with one of the material colors (depending on the color mode). This means you can use osg::Material to control the color of geometry even when lighting is disabled.
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> Hence, it makes no sense storing a color in ShapeDrawable.
Well, it makes as much sense as having a color array for an
osg::Geometry... :-)
I think it's not having a color in ShapeDrawable that's the problem,
it's having no way of having no color. In other words, in osg::Geometry
you have the ability to either set a color array or not. You should have
the same ability in ShapeDrawable, i.e. set a color or not. Since
osg::Color doesn't really have a "no color" value, you probably need an
additional bool saying "use the color or not". When _useColor == false,
then no glColor call would be made by ShapeDrawable itself, and the one
from osg::Material would take effect.
Or you could just do what Robert always says, ignore ShapeDrawable even
exists (except for simple debug geometry) and use osg::Geometry
directly. Then you can do what you want.
I've wanted to rewrite ShapeDrawable to use osg::Geometry internally for
a while, but I think Paul beat me to it in osgWorks... :-)
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
Well, I've made a start. Occasionally I even find time to add to it. Submissions
are welcome. :-)
In the context of the rest of this discussion, I'll mention that, some time ago,
we all discussed that osg::Material is more than just a wrapper around
glMaterial. It also owns glColorMaterial, and this actually makes it a little
difficult to enable/disable GL_COLOR_MATERIAL using StateSet::setMode() the way
you can with other OpenGL state. In the same vein, it seems that osg::Material
also wants to own the OpenGL primary color state (set with glColor). While it
might be a fun exercise to go back, rethink all this, and maybe implement a
substitute scheme, honestly I'd rather just use shaders...
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/