PDA

View Full Version : Polys staying white



matticus
02-12-2004, 04:10 AM
Hi Guys,

I've got an small program that draws some polygons and some GLUT primitives, and I'm changing the material (red/blue shiny/matt) between each item.

However, all the polygons appear solid pure white (no shading at all), whilst the GLUT stuff (spheres and teapots etc.) is shaded as I would expect them it be.

I don't see what I've missed.
I've defined normals, checked the order in which the vertices are defined, set up the lighting and so on. I can change the order which the objects are drawn, but the result is always the same.

Any ideas?

mikael_aronsson
02-12-2004, 06:34 AM
Make sure lighting is enabled when you render your triangles.

Mikael

matticus
02-12-2004, 06:40 AM
I've enabled it at the beginning of each frame.
And the light parameters must be sane because the teapots look nice and lickable.

Do I have to re-enable the lighting before each triangle?

02-12-2004, 10:45 AM
Do I have to re-enable the lighting before each triangle?

No. You only need to enable lighting ONCE, if you never disable it.

Triple check that there is no glDisable(GL_LIGHTING). And check your normals. I believe you draw your teapots with glu (or glut), and so the their normals are well defined.

matticus
02-15-2004, 12:08 AM
My polygons are flat wrt the screen.

If I have the normal facing out of the screen (0,0,-1) the polys are black.

If I have it facing into the screen (0, 0, 1), then the polys are white.

The glut stuff looks fine. Grrrr.

I can't believe I'm having problems doing something so basic! How stupid am I? http://www.opengl.org/discussion_boards/ubb/wink.gif

chowe6685
02-15-2004, 06:07 AM
how are you specifying your normals? I have a feeling something might be wrong with them

Relic
02-16-2004, 12:27 AM
First, you probably did everything right, but just don't know what the result should look like.
Corrections: Normals are specified in model
coordinates. OpenGL model (or object) coordinates are righthanded so (0,0,1) sticks out of the window in model (and world) coordinates per default.
Projected coordinates are left handed 0.0 is nearplane 1.0 is farplane.
That set straight, the default lighting is a white directional light down the negative z-axis in a right handed coordinate system for light 0, and all black for lights 1 - 7.

Solution: If you have a normal sticking straight out of the screen and a directional light straight into the screen, and default non-local viewer, you get a full white specular effect. What you see.

Try setting the specular color of the light to black, that should show diffuse only, or let the polygon rotate and keep the light static, or set the light position to shine from left-top-front.