Re: [Plib-users] Trouble making simple colored triangle
Brought to you by:
sjbaker
|
From: Ben D. <be...@wa...> - 2000-10-13 17:48:55
|
Hi Steve, thanks for the quick response!
> > if ( num_colours == 0 ) glColor4f ( 1.0f, 1.0f, 1.0f, 1.0f ) ;
> > This forces all primitives to white if they don't have a color per
vertex!
>
> No - it sets them to white if you didn't give the LEAF node a colour.
That's
> a very rare circumstance in practice.
I don't understand. The num_colors field comes from this:
int num_colours = getNumColours () ;
which is the number of colors in the vertex color table. I would presume in
general that more than one primitive will share the same vertex table, so
color information will come from the state, not the per-vertex colors. Or
are you saying that it is customary to make a ssgColourArray with a single
element in it, for each differently-colored primitive??
> > In ssgSimpleState::apply(), it uses glMaterialfv to set the diffuse
color.
> > However, GL is in "Color Material" mode by default, so the glMaterialfv
> > calls have no effect, making the shape default white.
>
> It's unwise to rely on OpenGL's default state. Many implementations get
> that wrong.
OK, i can set the state's state explicitly - but which is correct? Is
disabling GL_COLOR_MATERIAL required to get any ssgSimpleState-colored
objects?
> No - it's simply that you didn't enable or disable GL_COLOR_MATERIAL
explicitly
> and you didn't set the glColorMaterial setting to (say)
GL_AMBIENT_AND_DIFFUSE
> in the ssgStates that needed that.
I've tried that, and the triangle is still white, not green.
> > I tried to solve this problem by adding a statement to the triangle
code:
> > state->disable(GL_COLOR_MATERIAL);
>
> OK - that's going to mean that the polygon colour is entirely determined
by
> the glMaterial - but *ONLY* if GL_LIGHTING is enabled.
I've tried that, and the triangle is still white, not green.
> What OpenGL implementation do you have - and what PLIB are you using?
I'm using a NVidia Quadro under Win2k, presumably OGL1.2.
I've been using PLIB 1.2.0, but i looked at the latest 1.3.1 as well, and it
didn't appear to have changed in the core functionality i'm using.
> Yes - 99% of people put the colour in the leaf node and enable
> GL_COLOR_MATERIAL.
Does this mean i can't use ssgSimpleState? Using vertex colors ("in the
leaf node") means that the ssgSimpleState values are ignored, since they are
ignored by OpenGL when *not* using GL_COLOR_MATERIAL.
Wouldn't that also mean that i can't set additional properties like
Emission? You can't specify that with a ssgColourArray, so do 99% of people
not care about any state besides diffuse?
> Can you mail me a short example program so that I can investigate more
carefully?
I've attached a small example, which is basically the "tux" example with tux
replaced by a "green" triangle, which appears white.
Thanks!
Ben
|