/* * CS5600 University of Utah * Charles McGarvey * mcgarvey@eng.utah.edu */ #ifndef _LIGHT_H_ #define _LIGHT_H_ #include "color.h" #include "vec.h" /* * A light source. */ struct light { vec_t v; // position color_t d; // diffuse color_t s; // specular }; 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, color_t specular) { l->v = position; l->d = diffuse; l->s = specular; } /* * Create a new light with a position and color. */ INLINE_MAYBE light_t light_new(vec_t position, color_t diffuse, color_t specular) { light_t l; 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_