Skip to main content
GameDev.net gamedev.net
🔒 Locked

Light on everything

Started by bballmitch Jan 31, 2006 at 1:48 AM 4 replies 750+ views
Original Post
bballmitch
bballmitch
Im not exactly sure how to make ONE light that makes everything on screen light up?

     GLfloat mat_specular[]={0.5,0.5,0.5,1.0};              //Set the light...
     GLfloat light_position[]={0.0,0.0,10.0,1.0};          //If i want to add more lights later i can
     glClearColor (0.0,0.0,0.5,0.0);
     glShadeModel(GL_SMOOTH);
     glEnable(GL_DEPTH_TEST);
     glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
     glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 8.0);
     glLightfv(GL_LIGHT0, GL_POSITION, light_position);
     glEnable(GL_LIGHTING);
     glEnable(GL_LIGHT0);
     glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);

thats what my light 0 is right now. How would i alter it to make it so that the light looks like its coming from all directions and that it hits every object on screen?
Mitchen Games
dpadam450
dpadam450
First, why would you want light coming from all over? Do you just mean a sunlight coming from one direction? You could make 4 directional lights coming from the z and x axis. Btw, you have your light as a positional light, not directional. Not sure if you knew that.
NBA2K, Madden, Maneater, Killing Floor, Sims 
mrbastard
mrbastard
From your description, it sounds like you actually want to turn lighting off.
[size="1"]
b3rs3rk
b3rs3rk
use this
GLfloat light_position[]={0.0,0.0,10.0,0.0};

the last component set to 0.0 makes your light global and omnidirectional. See the opengl guide for complete description.
cherryhouse
cherryhouse
I'm pretty sure he's just refering to ambient lighting.

[Edited by - cherryhouse on January 31, 2006 7:30:01 AM]
Hello?
b3rs3rk
b3rs3rk
oh. well... take a look at nehe's tutorial #7.

GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.