X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Frasterize;a=blobdiff_plain;f=light.h;h=2518927117d50d43590bb3d78df132e2aaff7a9e;hp=99c0d7c3abfa1aee87c0911066e4f142c0eb3302;hb=09dd89d10e65029f0be313dd463ba1f43cac2fbb;hpb=c875478cdd823c7df8fdc859941bd9e5948c9315 diff --git a/light.h b/light.h index 99c0d7c..2518927 100644 --- a/light.h +++ b/light.h @@ -17,34 +17,55 @@ */ 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_