Add Texture module

This commit is contained in:
Eryn Wells 2013-09-07 22:12:27 -07:00
parent 830979fc75
commit e77e9488c0
3 changed files with 81 additions and 0 deletions

View file

@ -10,6 +10,7 @@ files = Split("""
charles.c
object.c
scene.c
texture.c
writer_png.c
""")

60
src/texture.c Normal file
View file

@ -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 <eryn@erynwells.me>
*/
#include <assert.h>
#include <stdlib.h>
#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;
}

20
src/texture.h Normal file
View file

@ -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 <eryn@erynwells.me>
*/
#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