PDA

View Full Version : glut light



mairan21
12-03-2014, 01:53 PM
1523


glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

// Create light components
GLfloat ambientLight[] = { 0.2f, 0.2f, 0.2f, 1.0f };
GLfloat diffuseLight[] = { 0.8f, 0.8f, 0.8, 1.0f };
GLfloat specularLight[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position[] = { 1.5f, 1.0f, 1.0f, 1.0f };

// Assign created components to GL_LIGHT0
glLightfv(GL_LIGHT0, GL_AMBIENT, ambientLight);
glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuseLight);
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLight);
glLightfv(GL_LIGHT0, GL_POSITION, position);

I do not know how to make good lighting to my game, please that any help? Thx

ParagonArcade
12-03-2014, 02:19 PM
What version of OpenGL are you using? That is all deprecated code, i.e. not used anymore. You may want to look at using GLSL. Pretty simple to set up basic lightning once you understand shaders.

GClements
12-03-2014, 04:24 PM
You should probably use light maps for ambient lighting, using real-time lighting only where necessary.