diff --git a/src/SConscript b/src/SConscript index 57857aa..d3756b7 100644 --- a/src/SConscript +++ b/src/SConscript @@ -10,6 +10,7 @@ files = Split(""" charles.c object.c scene.c + texture.c writer_png.c """) diff --git a/src/texture.c b/src/texture.c new file mode 100644 index 0000000..945232d --- /dev/null +++ b/src/texture.c @@ -0,0 +1,60 @@ +/* texture.c + * + * Definition of Texture object. Texture objects are attached to scene objects and define its color and shader. + * + * Eryn Wells + */ + +#include +#include + +#include "basics.h" +#include "texture.h" + + +struct _Texture { + Color color; +}; + + +/* + * texture_init -- + * + * Allocate and create a new Texture. + */ +Texture * +texture_init() +{ + Texture *tex = malloc(sizeof(Texture)); + if (tex == NULL) { + return NULL; + } + + tex->color = ColorBlack; + + return tex; +} + + +void +texture_destroy(Texture *tex) +{ + assert(tex != NULL); + free(tex); +} + + +Color +texture_get_color(Texture *tex) +{ + assert(tex != NULL); + return tex->color; +} + + +void +texture_set_color(Texture *tex, Color color) +{ + assert(tex != NULL); + tex->color = color; +} diff --git a/src/texture.h b/src/texture.h new file mode 100644 index 0000000..202cf7a --- /dev/null +++ b/src/texture.h @@ -0,0 +1,20 @@ +/* texture.h + * + * Declaration of Texture object. Texture objects are attached to scene objects and define its color and shader. + * + * Eryn Wells + */ + +#ifndef __TEXTURE_H__ +#define __TEXTURE_H__ + + +typedef struct _Texture Texture; + +Texture *texture_init(); +void texture_destroy(Texture *tex); +Color texture_get_color(Texture *tex); +void texture_set_color(Texture *tex, Color color); + + +#endif