summaryrefslogtreecommitdiffstats
path: root/light.c
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-10-24 17:04:02 +0200
committerneoraider <devnull@localhost>2006-10-24 17:04:02 +0200
commite43bceafaba72d34dfbea1deecd56c2f694d704a (patch)
treef403b0e076df599084d55bf04e546b565731e3c6 /light.c
parent79801b6b794a5fb50a3a013354323a48de37c050 (diff)
downloadlibzoom-e43bceafaba72d34dfbea1deecd56c2f694d704a.tar
libzoom-e43bceafaba72d34dfbea1deecd56c2f694d704a.zip
Beleuchtung und Rendering ge?ndert, um Schatten zu erm?glichen.
Diffstat (limited to 'light.c')
-rw-r--r--light.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/light.c b/light.c
new file mode 100644
index 0000000..dcea864
--- /dev/null
+++ b/light.c
@@ -0,0 +1,45 @@
+#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);
+}