Hi JS,

Are you doing a :

 stateset->setAttributeAndModes(material);

If so then if you use a 1.2 or before the above will enable
GL_COLOR_MATERIAL.  In CVS it doesn't so you usage should be fine.

Robert.

On 12/16/06, Jean-Sebastien Guay <[EMAIL PROTECTED]> wrote:
Hello Robert,

> As a general guide, with OpenGL setting the glColor on many seperate
> objects will be faster than setting it via glMaterial.
> Another general hint is the using ShapeDrawable to render sphere's is
> not efficient, [...]

I am not looking for speed right now, just wondering why it isn't doing what I
think it should be doing...

> Finally, glMaterial and glColor interact, with glColour override the
> glMaterial (that is used for the final lighting calculation).  You
> really need to read up on glMaterial/glColorMaterial in OpenGL docs
> for a good explanation of the what the ins and outs are.
> Material::setColorMode is the OSG's equivilant to glColorMaterial.

I am not using glColorMaterial, as the default for Material is _colorMode = OFF
(as per the osg::Material constructor).

I'm sorry, perhaps I gave you the impression I had not put any work into solving
this myself... Here is what I think is happening, please correct where I am
wrong (I am obviously wrong somewhere, since I'm not getting the results I
think I should).

If I am not mistaken, the flow is more or less like this in the draw traversal:

[...]

- encounter Material (on one of the geode's parent nodes)
    Material::apply(State&)
        glDisable(GL_COLOR_MATERIAL);      // because _colorMode is OFF
        glColor4fv(_diffuseFront.ptr());   // which has no effect since
                                              GL_COLOR_MATERIAL is disabled
        glMaterialfv(ambient)              // pseudocode
        glMaterialfv(diffuse)
        glMaterialfv(specular)
        glMaterialfv(emissive)
        glMaterialf(shininess)
    end Material::apply(State&)
- encounter ShapeDrawable (in a Geode which is a child of the node containing
                           the Material)
    ShapeDrawable::drawImplementation(State& state)
        glColorfv(_color.ptr()); (which has no effect, as above)
        draw the shape with a DrawShapeVisitor
    end ShapeDrawable::drawImplementation(State& state)

[...]

So, if the above is correct, if the Material's diffuse front-face color is red,
then the sphere should be red. The DrawShapeVisitor never sets any color or
material properties, so unless someone else enables GL_COLOR_MATERIAL behind my
back, the Material should have the desired effect. Can someone help me spot my
mistake? _Is_ anyone re-enabling GL_COLOR_MATERIAL behind my back?

Thanks in advance,

J-S
--
______________________________________________________
Jean-Sebastien Guay     [EMAIL PROTECTED]
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to