PDA

View Full Version : How to turn on/off light between 2D and 3D object



zhangjunyue
04-01-2004, 10:11 PM
I write some source codes to draw using OpenGL.
Some entitis are 2D, others are 3D. Here is my sample codes:

//initial, light is on.

glDisable(GL_LIGHTING);
...
draw 2d entities.
...
glEnable(GL_LIGHTING);

...
draw 3d entites.
...

I found there is not shading on 3D entities, why? Could anyone give me some suggestions?

Tom Nuydens
04-01-2004, 10:56 PM
Moving to the beginners forum.

-- Tom

eror
04-02-2004, 03:17 AM
Post your code which you are really using.

Are you sure you turn on proper lights?

Deiussum
04-02-2004, 05:48 AM
The quick answer is to make sure you:

Turn on appropriate lights (e.g. glEnable(GL_LIGHT0) Set light params appropriately. (e.g. glLight(...) Make sure you specify material settings (e.g. glMaterial(...)) Make sure to specify normals appropriately. (e.g. glNormal(...))

chowe6685
04-02-2004, 07:40 AM
could also be a lack of tesselation, see #2

http://www.opengl.org/resources/features/KilgardTechniques/oglpitfall/

zhangjunyue
04-04-2004, 05:40 PM
Thanks for hints, It is my program pitfall.