rendered paste body** Light.h **
#include <windows.h> // Header File For The Windows Library
#include <stdio.h> // Header File For Standard Input/Output
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\glaux.h> // Header File For The GLaux Library
class Light {
public:
Light();
~Light();
void switchLight(BOOL);
void init(void);
private:
BOOL light; // Lighting ON / OFF
BOOL lp; // L Pressed?
GLfloat LightAmbient[4];
GLfloat LightDiffuse[4];
GLfloat LightPosition[4];
};
** Light.cpp **
#include "Light.h"
Light::Light() {
LightAmbient = { 0.5f, 0.5f, 0.5f, 1.0f };
LightDiffuse = { 1.0f, 1.0f, 1.0f, 1.0f };
LightPosition = { 0.0f, 1.0f, 2.0f, 1.0f };
glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); // Setup The Ambient Light
glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); // Setup The Diffuse Light
glLightfv(GL_LIGHT1, GL_POSITION,LightPosition); // Position The Light
glEnable(GL_LIGHT1); // Enable Light One
}
Light::~Light() {
}
void Light::switchLight(BOOL lp) {
if (!Light::lp && lp) {
lp=TRUE;
light=!light;
if (!light) {
glDisable(GL_LIGHTING);
}
else {
glEnable(GL_LIGHTING);
}
}
Light::lp = lp;
}