Hi
I’m having problems with colour and lighting - red doesn’t seem to display and also when rotating the scene - part of it seem to get dimmer than other parts - this seems to be related to the parameter in diffuselight - below is some code - any ideas?
//in InitOpenGl
[ccode]
GLfloat LightAmbient[] = {0.5f, 0.5f, 0.5f, 0.5f}; //Ambient light values
GLfloat LightDiffuse[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Diffuse light values
// x y z
GLfloat LightPosition[]= {0.0f, 0.0f, 10.0f, 1.0}; //Light position
if(!object.LoadGLTextures())
{
return FALSE;
}
glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); //Setup the Ambient light
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); //Setup the Diffuse light
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); // Position the Light
glEnable(GL_TEXTURE_2D); //Enable texture mapping
glEnable(GL_POLYGON_SMOOTH);
glShadeModel(GL_SMOOTH); //Enable smooth shading
glEnable(GL_LINE_SMOOTH); //makes grids on floor look smooth
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); //Black background
glClearDepth(1.0f); //Depth buffer setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); //Nice perspective calculations
glEnable(GL_LIGHT0); //brightens the scene
glEnable(GL_LIGHTING);
In onPaint()
problem of colour appearing brighter and then dimmer
glPushMatrix();
glEnable(GL_BLEND);
glDisable(GL_LIGHTING);
glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
glBlendFunc(GL_ONE, GL_ONE);
object.DrawFloor();
glEnable(GL_LIGHTING);
glDisable(GL_BLEND);
glPopMatrix();
[/ccode]
cheers