• 15
• 15
• 11
• 9
• 10

# Lights

This topic is 3724 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Am trying to make a light bulb/something tt gives out light. But currently, i have problems making the polygons emit lights.. It give me a black color object when i tried to define the material properties. Anyone can teach me how to do it from the beginning? Or give me nice tutorials? Thanks a millions [Edited by - SnowMoo on January 12, 2008 6:11:47 AM]

##### Share on other sites
The DirectX SDK has a tutorial on using lights (tutorial 4).

##### Share on other sites
Quote:
 Original post by Gage64The DirectX SDK has a tutorial on using lights (tutorial 4).

huh? DirectX SDK? I'm trying to do in OpenGL

##### Share on other sites
Sorry, don't know why I assumed you were using DirectX, and also didn't notice that you posted this in the OpenGL forum...

In that case, have a look here.

##### Share on other sites
Quote:
 Original post by Gage64Sorry, don't know why I assumed you were using DirectX, and also didn't notice that you posted this in the OpenGL forum...In that case, have a look here.

Thanks for the link. However, all my glutSolidCube are in black color even though i placed glColor3f before them. Can anyone help me?

void MyDisplay(void){		GLfloat no_mat[] = { 1.0, 1.0, 1.0, 1.0 };	GLfloat mat_diffuse[] = { 1.1, 1.5, 1.8, 1.0 };	GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };	GLfloat low_shininess[] = { 5.0 };	GLfloat mat_emission[] = {0.3, 0.2, 0.2, 0.0};	GLfloat no_shininess[] = { 0.0 };	// Clear the window with current clearing color	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	glMatrixMode(GL_MODELVIEW);	glLoadIdentity();	gluLookAt(	camera.mEyeX,				camera.mEyeY,				camera.mEyeZ,					//x, y, z of viewpoint location		camera.mLookX+camera.mEyeX,	camera.mLookY+camera.mEyeY,	camera.mLookZ+camera.mEyeZ,		//x, y, z of observation point		camera.mUpX,				camera.mUpY,				camera.mUpZ);					//x, y, z of up direction		glPushMatrix();				glTranslatef(0,0,10);			Room();		glPushMatrix();			glTranslatef(0,100,0);				glMaterialfv(GL_FRONT, GL_AMBIENT, no_mat);			glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);			glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat);			glMaterialfv(GL_FRONT, GL_SHININESS, no_shininess);			glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission);			glColor3f(1,1,1);			glutSolidCube(4.0);		glPopMatrix();			glPopMatrix();	glutSwapBuffers();}

##### Share on other sites
As far as I know, the glColor*() calls have no effect when using lighting. Also, you are specifying the materials, but you also need to specify the lights and their properties, as well as enable lighting (don't remember if it's enabled by default). The link I gave should show you how to do all this.

##### Share on other sites
glColor*f has no effect when lighting is enabled. The question really is, are you calling glNormal3f for every vertex you pass?

##### Share on other sites
glutSolidCube has no normals, so u need to write your own cube vertices, triangles, etc. Something about that is on www.codesampler.com