PDA

View Full Version : Why are certain objects white?



04-23-2003, 10:26 AM
I have a 3D world which is a model of a room I don't know how to put the lighting in. I created the room using translating cubes throughout the room. However, I did it relatively to a larger cube. For example, I have a desk. I first drew the desktop by translating from the center of the room to the place where the desk was to be created. Then, relative to the desktop I drew the legs by translating from the desktop to the place where I wanted to put the legs. So, I pushed a matrix and without popping the desktop matrix I pushed the desk leg matrices. Now, I don't know how to use lighting. Is it possible to do this with the situation I have in my program? What causes certain things to turn completely white when I turn the light on?

Deiussum
04-23-2003, 11:57 AM
glColor doesn't work the same with lighting enabled. Instead you set the color of material properties. If you want, you can enable GL_COLOR_MATERIAL and use the glColorMaterial function in order to be able to use glColor to set some of the material colors, though.

Also, when you enable lighting, you need to make sure you specify your normals.

04-23-2003, 02:15 PM
What do you mean by normals? Also, what are the arguments/parameters for the GlColorMaterial function, and when can I use it. Does this mean that I cannot use glColor anymore?

nexusone
04-23-2003, 04:39 PM
Just means you need to learn more about 3D programming...

nehe.gamedev.net is a good site to learn about lighting and normals.

You still can use glcolor, just works a little diffrent.



Originally posted by helpmeout please:
What do you mean by normals? Also, what are the arguments/parameters for the GlColorMaterial function, and when can I use it. Does this mean that I cannot use glColor anymore?

Deiussum
04-24-2003, 04:27 AM
Normals are vectors that are used for lighting calculations. Generally the normal for a triangle is perpendicular to the surface pointing the direction that light would be reflected if it hit the face straight on. Generally to get smooth shading, you specify normals for each vertex, where you take the normalized average of all triangles that share that vertex. (Normalized means that the vector it's a length of 1)

For the parameters used in glMaterial, check sources like MSDN and the RedBook, both of which can be found online.