/* * CS5600 University of Utah * Charles McGarvey * mcgarvey@eng.utah.edu */ #ifndef _LIGHT_HH_ #define _LIGHT_HH_ #include "color.hh" #include "vec.hh" /* * A light source. */ struct light { vec_t v; // position color_t d; // diffuse }; typedef struct light light_t; /* * Initialize a light with a position and color. */ INLINE_MAYBE void light_init(light_t* l, vec_t position, color_t diffuse) { l->v = position; l->d = diffuse; } /* * Create a new light with a position and color. */ INLINE_MAYBE light_t light_new(vec_t position, color_t diffuse) { light_t l; light_init(&l, position, diffuse); return l; } /* * Create a new light on the heap. */ INLINE_MAYBE light_t* light_alloc(vec_t position, color_t diffuse) { light_t* l = (light_t*)mem_alloc(sizeof(light_t)); light_init(l, position, diffuse); 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_HH_