45 lines
690 B
C
45 lines
690 B
C
#include <stdlib.h>
|
|
#include <zoom/light.h>
|
|
#include <GL/gl.h>
|
|
|
|
|
|
int nLights = 0;
|
|
LIGHT *lights;
|
|
|
|
static COLOR ambient;
|
|
|
|
|
|
static void UpdateAmbient() {
|
|
glClearColor(ambient.r/(nLights+1), ambient.g/(nLights+1), ambient.b/(nLights+1), 1.0);
|
|
}
|
|
|
|
void SetAmbient(COLOR c) {
|
|
ambient = c;
|
|
|
|
UpdateAmbient();
|
|
}
|
|
|
|
void AddLight(LIGHT light) {
|
|
if(nLights == 0)
|
|
lights = malloc(sizeof(LIGHT));
|
|
else
|
|
lights = realloc(lights, sizeof(LIGHT)*(nLights+1));
|
|
|
|
lights[nLights] = light;
|
|
nLights++;
|
|
|
|
UpdateAmbient();
|
|
}
|
|
|
|
void ResetLights() {
|
|
if(nLights > 0) {
|
|
free(lights);
|
|
nLights = 0;
|
|
UpdateAmbient();
|
|
}
|
|
}
|
|
|
|
void ApplyLightScale() {
|
|
glAccum(GL_LOAD, 1);
|
|
glAccum(GL_RETURN, nLights+1);
|
|
}
|