Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

HellRiZZer

OpenGL OpenGL Materials, crying..... :((

This topic is 6087 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

I just messed up with use of materials in OpenGL. Please, please someone help me and tell me what do I have to enable and disable to PROPERLY use materials because I''m stuffed up with them!!! (( How do I use materials for evaluators or plain models etc, how do I set them up e.g in separate class etc... PLEASE PLEASE SOMEONE!! ((( " Do we need us? "

Ionware Productions - Games and Game Tools Development

Share this post


Link to post
Share on other sites
Advertisement
  

GLfloat l0_ambient[] = { 0.1, 0.1, 0.1, 1.0 };
GLfloat l0_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat l0_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat l0_position[] = { 1.0, 1.0, 1.0, 0.0 }; // 0.0 means light at infinity


GLfloat mat_ambient[] = { 1.0, 0.0, 0.0, 1.0 }; // red

GLfloat mat_diffuse[] = { 1.0, 0.0, 0.0, 1.0 }; // red too !

GLfloat mat_specular[] = { 1.0, 0.0, 0.0, 1.0 }; // white highlight...

GLfloat mat_shininess[] = { 5.0 }; // Phong exponent



glEnable( GL_LIGHTING ); // Enable (Phong) lighting

glEnable( GL_LIGHT0 ); // Enable light #0

glEnable( DEPTH_TEST ); // Z buffer

glShadeModel( GL_SMOOTH ); // Gouraud shading


glMaterialfv( GL_FRONT, GL_AMBIENT, mat_ambient );
glMaterialfv( GL_FRONT, GL_DIFFUSE, mat_diffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, mat_specular );
glMaterialfv( GL_FRONT, GL_SHININESS, mat_shininess );

glLightfv( GL_LIGHT0, GL_AMBIENT, l0_ambient );
glLightfv( GL_LIGHT0, GL_DIFFUSE, l0_diffuse );
glLightfv( GL_LIGHT0, GL_SPECULAR, l0_specular );
glLightfv( GL_LIGHT0, GL_POSITION, l0_position ); // Position IS modified by the MODELVIEW matrix



It''s in the Red Book, you should have looked it up.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!