How would one go about putting a light source in a sphere, but have it shine outside of it like the Sun? I used GLU for the sphere.
Thanks.
Lack
Christianity, Creation, metric, Dvorak, and BeOS for all!
Some quick OpenGL help
Hi Lack,
I think the way to do it is to push the lighting attribute bit, disable lighting, draw your sun, then re-enable lighting for the rest of the scene (sorry, my brain''s gone all rusty ).
The code may look similar to this:
Sorry if this a little vague, but I think that''s the general approach. If it doesn''t work... um... give up?
thankyoubye
-------------
squirrels are a remarkable source of protein...
I think the way to do it is to push the lighting attribute bit, disable lighting, draw your sun, then re-enable lighting for the rest of the scene (sorry, my brain''s gone all rusty ).
The code may look similar to this:
glPushMatrix() //save matrix state, in case you have a viewing transformationglPushAttrib(GL_LIGHTING_BIT)glDisable(GL_LIGHTING)//perform transforms for positioning sun...gluSolidSphere(...) //whatever it is to draw sphereglEnable(GL_LIGHTING) //restore lighting for rest of scene//probably a call to pop attribute here (can''t remember)glPopAttrib()glPopMatrix() //restore matrix state
Sorry if this a little vague, but I think that''s the general approach. If it doesn''t work... um... give up?
thankyoubye
-------------
squirrels are a remarkable source of protein...
No, don''t do it like that... do it like this
float bright[4]={1,1,1,1}
glPushAttrib(GL_LIGHTING_BIT);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, bright);
//draw your sun thing here
glPopAttrib();
I''m using the same technique in my breakout-style game to make the powerups stand out from the rest of the blocks.
http://www.geocities.com/ben32768
float bright[4]={1,1,1,1}
glPushAttrib(GL_LIGHTING_BIT);
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, bright);
//draw your sun thing here
glPopAttrib();
I''m using the same technique in my breakout-style game to make the powerups stand out from the rest of the blocks.
http://www.geocities.com/ben32768
Thanks, guys. But when I put the source in the middle of the sphere so that the light''s even, it goes dark altogether. Eugh?
Lack
Christianity, Creation, metric, Dvorak, and BeOS for all!
Lack
Christianity, Creation, metric, Dvorak, and BeOS for all!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement