]> Dogcows Code - chaz/rasterize/blobdiff - light.h
add external supersampling to animate script
[chaz/rasterize] / light.h
diff --git a/light.h b/light.h
index 99c0d7c3abfa1aee87c0911066e4f142c0eb3302..2518927117d50d43590bb3d78df132e2aaff7a9e 100644 (file)
--- a/light.h
+++ b/light.h
  */
 struct light
 {
-    color_t color;
-    vec_t   position;
+    vec_t   v;  // position
+    color_t d;  // diffuse
+    color_t s;  // specular
 };
 typedef struct light light_t;
 
-
 /*
- * Initialize a light with a color and position.
+ * Initialize a light with a position and color.
  */
 INLINE_MAYBE
-void light_init(light_t* l, color_t color, vec_t position)
+void light_init(light_t* l, vec_t position, color_t diffuse, color_t specular)
 {
-    l->color = color;
-    l->position = position;
+    l->v = position;
+    l->d = diffuse;
+    l->s = specular;
 }
 
 
 /*
- * Create a new light with a color and position.
+ * Create a new light with a position and color.
  */
 INLINE_MAYBE
-light_t light_new(color_t color, vec_t position)
+light_t light_new(vec_t position, color_t diffuse, color_t specular)
 {
     light_t l;
-    light_init(&l, color, position);
+    light_init(&l, position, diffuse, specular);
     return l;
 }
 
 
+/*
+ * Create a new light on the heap.
+ */
+INLINE_MAYBE
+light_t* light_alloc(vec_t position, color_t diffuse, color_t specular)
+{
+    light_t* l = (light_t*)mem_alloc(sizeof(light_t));
+    light_init(l, position, diffuse, specular);
+    return l;
+}
+
+INLINE_MAYBE
+light_t* light_copy(light_t l)
+{
+    light_t* n = (light_t*)mem_alloc(sizeof(light_t));
+    memcpy(n, &l, sizeof(light_t));
+    return n;
+}
+
+
 #endif // _LIGHT_H_
 
This page took 0.01883 seconds and 4 git commands to generate.