lighting problems
im attempting to add a light source to my program but having no success...
i basically just took the code from tut. 7 and pasted it where it should go (at least i think i put it where it should go)
in the declarations i have...
GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat LightPosition[]= { 3.0f, 1.0f, 1.0f, 1.0f };
in the InitGL(GLvoid) i have...
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition);
glEnable(GL_LIGHT1);
i have the glEnable(GL_LIGHTING); in the top of drawglscene, is that where it''s supposed to go? wherever i seem to put it, it doesn''t work; the screen turns completely black
Thanks,
-Drew
glEnable(GL_LIGHTING); can go in your initialize function. Don''t put it in your render loop.
(Correct me if I''m wrong on this) For an object to recieve light, you must use a material. The material is used in the lighting calculations. The material will tell the object how much light to reflect or absorb. For instance, if you have a material of RGB(0, 0, 1) it will absorb the red and green colors, but reflect the blue. If theres no material at all, it doesn''t know what to reflect or absorb.
In other words, add a material and it should work fine.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
(Correct me if I''m wrong on this) For an object to recieve light, you must use a material. The material is used in the lighting calculations. The material will tell the object how much light to reflect or absorb. For instance, if you have a material of RGB(0, 0, 1) it will absorb the red and green colors, but reflect the blue. If theres no material at all, it doesn''t know what to reflect or absorb.
In other words, add a material and it should work fine.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
No,materials are not needed. But normals are. Are u specifying the normals for the polys?
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Nope, no material required. I never use materials.
It sounds like you don't have normals on your geometry, which is why it's all going black. You need to tell OpenGL which way your geometry is facing so it knows how to light things properly.
EDIT: Gah, beaten to it
[edited by - LockePick on July 29, 2003 11:31:21 PM]
It sounds like you don't have normals on your geometry, which is why it's all going black. You need to tell OpenGL which way your geometry is facing so it knows how to light things properly.
EDIT: Gah, beaten to it

[edited by - LockePick on July 29, 2003 11:31:21 PM]
_______________________________________Pixelante Game Studios - Fowl Language
July 29, 2003 10:35 PM
quote:
Original post by LockePick
EDIT: Gah, beaten to it![]()
<SPAN CLASS=editedby>[edited by - LockePick on July 29, 2003 11:31:21 PM]</SPAN>
Thats what u get when u mess with speedy tHiSiSbObzalez
how do i specify normals... i thought by rendering all the objects in the topright corner first, then topleft corner, then bottomleft corner, then bottomright corner it would make them face the right way... that''s the impression i got from one of the first tuts. anyway
Thats for backface culling. They''re talking about using the normals. Heres a tutorial on doing normals.
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
-UltimaX-
"You wished for a white christmas... Now go shovel your wishes!"
still not working... im slowly adding normals to everything but im not getting any results so far.. the screen still stays black. when i put glEnable(GL_LIGHTING); in the init function the program works fine... except there's no light... when i put it anywhere else the screen just goes black i would post the code but i made all the polys by hand so there's a lot of crap to sift through. do i need to have every poly have a normal before it will work properly.. cause im thinking the poly's ive done so far should at least show up...
[edited by - heat511 on July 30, 2003 1:09:39 AM]
[edited by - heat511 on July 30, 2003 1:09:39 AM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement