Jump to content
  • Advertisement
Sign in to follow this  
SnowMoo

Lights

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Gage64
The DirectX SDK has a tutorial on using lights (tutorial 4).


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

Share this post


Link to post
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 this post


Link to post
Share on other sites
Quote:
Original post by Gage64
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.


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 this post


Link to post
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!