Black lines

This is embarrassing. In my previous message “More Black Surfaces” Relic helped get my surface colored properly by setting the glLightModel…() correctly. Now I’d like to display a grid, but again when I go to the bottom view the lines are black instead of the colors I’d like them to be, ie red front, yellow back. Actually, they look sort of brownish, like they’re red but unlit. The grid is drawn before the model and uses the same environment as the model. I use glMaterialfv() to set the grid color. The normal for the lines is (0,0,1).

Do I need to set the BACK material for lines? Do I need to use normals for lines?

If you set the color of the lines to 1,0,0 (red), and the lines look dark-red, then that clearly means that it is “lit”. If you want the grid line to be it’s absolute color, then make sure you disable lighting before drawing the grid lines.

…or, your lines are being blended somehow.

Or you could have forgotten to disable texturing before you render the lines.

Jan.

Originally posted by macfiend:
If you set the color of the lines to 1,0,0 (red), and the lines look dark-red, then that clearly means that it is “lit”. If you want the grid line to be it’s absolute color, then make sure you disable lighting before drawing the grid lines.

I think the line is being “lit” by ambient light which I think is on when you enable lighting. It’s also has not been changed from its default value. Whatever. I now disable lighting in the grid drawing code and use glColor*() instead of glMaterial*() and it works.

But why do I need to do this? It seems like GL is treating lines differently than it does surfaces. Why can’t I turn lighting on and set a material and have it produce the right thing?

That’s the thing. OpenGL <u>IS</u> treating the lines just like it treats everything else. To OpenGL, lines and polygons are just groups of pixels.

Anyway, lighting in OpenGL doesn’t necessarily mean “brightening” an object, which is what it seems like you are thinking. When lighting is enabled, and you draw two of the same object; one under the light, and one far away from the light, the one under the light will appear to be brigther than the further one (assuming you have all your normals and lighting setup realistically).