From 5138e55d3eb41255b1436d40ceba134876c3c5cd Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 9 Nov 2009 15:20:58 -0500 Subject: Add support for finishes (BRDFs). --- libdimension/texture.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'libdimension/texture.c') diff --git a/libdimension/texture.c b/libdimension/texture.c index 3867628..a9d7de1 100644 --- a/libdimension/texture.c +++ b/libdimension/texture.c @@ -21,7 +21,7 @@ #include "dimension.h" #include /* For malloc */ -/* Allocate an dummy pigment */ +/* Allocate a dummy pigment */ dmnsn_pigment * dmnsn_new_pigment() { @@ -44,6 +44,29 @@ dmnsn_delete_pigment(dmnsn_pigment *pigment) } } +/* Allocate a dummy finish */ +dmnsn_finish * +dmnsn_new_finish() +{ + dmnsn_finish *finish = malloc(sizeof(dmnsn_finish)); + if (finish) { + finish->free_fn = NULL; + } + return finish; +} + +/* Free a finish */ +void +dmnsn_delete_finish(dmnsn_finish *finish) +{ + if (finish) { + if (finish->free_fn) { + (*finish->free_fn)(finish->ptr); + } + free(finish); + } +} + /* Allocate a dummy texture */ dmnsn_texture * dmnsn_new_texture() @@ -51,15 +74,17 @@ dmnsn_new_texture() dmnsn_texture *texture = malloc(sizeof(dmnsn_texture)); if (texture) { texture->pigment = NULL; + texture->finish = NULL; } return texture; } -/* Free a dummy texture */ +/* Free a texture */ void dmnsn_delete_texture(dmnsn_texture *texture) { if (texture) { + dmnsn_delete_finish(texture->finish); dmnsn_delete_pigment(texture->pigment); free(texture); } -- cgit v1.2.3