summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-31 14:08:36 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-31 14:13:38 -0400
commitc42fd6547afed0b65260ae6a8a07cf9dcf084b67 (patch)
treed0cf947f8b7a2c4ae0e5f6151da3ff656f663f57 /libdimension/dimension
parentc10255ab3da17507d63bdc7e1fdfc809ffd32f7f (diff)
downloaddimension-c42fd6547afed0b65260ae6a8a07cf9dcf084b67.tar.xz
finish: Use pool.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/finish.h64
-rw-r--r--libdimension/dimension/finishes.h18
2 files changed, 18 insertions, 64 deletions
diff --git a/libdimension/dimension/finish.h b/libdimension/dimension/finish.h
index 5f2443b..d975877 100644
--- a/libdimension/dimension/finish.h
+++ b/libdimension/dimension/finish.h
@@ -28,13 +28,10 @@
/** Ambient finish component. */
typedef struct dmnsn_ambient {
dmnsn_color ambient; /**< Ambient light. */
- DMNSN_REFCOUNT; /**< Reference count. */
} dmnsn_ambient;
-/** Allocate a dummy ambient component. */
-dmnsn_ambient *dmnsn_new_ambient(dmnsn_color ambient);
-/** Delete an ambient component. */
-void dmnsn_delete_ambient(dmnsn_ambient *ambient);
+/** Allocate an ambient component. */
+dmnsn_ambient *dmnsn_new_ambient(dmnsn_pool *pool, dmnsn_color ambient);
/* Diffuse component */
@@ -53,26 +50,15 @@ typedef dmnsn_color dmnsn_diffuse_fn(const dmnsn_diffuse *diffuse,
dmnsn_color light, dmnsn_color color,
dmnsn_vector ray, dmnsn_vector normal);
-/**
- * Diffuse destruction callback.
- * @param[in,out] diffuse The diffuse object to destroy.
- */
-typedef void dmnsn_diffuse_free_fn(dmnsn_diffuse *diffuse);
-
/** Diffuse finish component. */
struct dmnsn_diffuse {
dmnsn_diffuse_fn *diffuse_fn; /**< Diffuse callback. */
- dmnsn_diffuse_free_fn *free_fn; /**< Destructor callback. */
-
- DMNSN_REFCOUNT; /**< Reference count. */
};
/** Allocate a dummy diffuse component. */
-dmnsn_diffuse *dmnsn_new_diffuse(void);
+dmnsn_diffuse *dmnsn_new_diffuse(dmnsn_pool *pool);
/** Initialize a dmnsn_diffuse field. */
void dmnsn_init_diffuse(dmnsn_diffuse *diffuse);
-/** Delete a diffuse component. */
-void dmnsn_delete_diffuse(dmnsn_diffuse *diffuse);
/* Specular component */
@@ -93,26 +79,15 @@ typedef dmnsn_color dmnsn_specular_fn(const dmnsn_specular *specular,
dmnsn_vector ray, dmnsn_vector normal,
dmnsn_vector viewer);
-/**
- * Specular destruction callback.
- * @param[in,out] specular The specular object to destroy.
- */
-typedef void dmnsn_specular_free_fn(dmnsn_specular *specular);
-
/** Specular finish component. */
struct dmnsn_specular {
dmnsn_specular_fn *specular_fn; /**< Specular callback. */
- dmnsn_specular_free_fn *free_fn; /**< Destructor callback. */
-
- DMNSN_REFCOUNT; /**< Reference count. */
};
/** Allocate a dummy specular component. */
-dmnsn_specular *dmnsn_new_specular(void);
+dmnsn_specular *dmnsn_new_specular(dmnsn_pool *pool);
/** Initialize a dmnsn_specular field. */
void dmnsn_init_specular(dmnsn_specular *specular);
-/** Delete a specular component. */
-void dmnsn_delete_specular(dmnsn_specular *specular);
/* Reflection component */
@@ -131,34 +106,23 @@ typedef dmnsn_color dmnsn_reflection_fn(const dmnsn_reflection *reflection,
dmnsn_color reflect, dmnsn_color color,
dmnsn_vector ray, dmnsn_vector normal);
-/**
- * Reflection destruction callback.
- * @param[in,out] reflection The reflection object to destroy.
- */
-typedef void dmnsn_reflection_free_fn(dmnsn_reflection *reflection);
-
/** The reflection component. */
struct dmnsn_reflection {
dmnsn_reflection_fn *reflection_fn; /**< Reflection callback. */
- dmnsn_reflection_free_fn *free_fn; /**< Destructor callback. */
-
- DMNSN_REFCOUNT; /**< Reference count. */
};
/** Allocate a dummy reflection component. */
-dmnsn_reflection *dmnsn_new_reflection(void);
+dmnsn_reflection *dmnsn_new_reflection(dmnsn_pool *pool);
/** Initialize a dmnsn_reflection field. */
void dmnsn_init_reflection(dmnsn_reflection *reflection);
-/** Delete a reflection component. */
-void dmnsn_delete_reflection(dmnsn_reflection *reflection);
/* Entire finishes */
/** A finish. */
typedef struct dmnsn_finish {
- dmnsn_ambient *ambient; /**< Ambient component. */
- dmnsn_diffuse *diffuse; /**< Diffuse component. */
- dmnsn_specular *specular; /**< Specular component. */
+ dmnsn_ambient *ambient; /**< Ambient component. */
+ dmnsn_diffuse *diffuse; /**< Diffuse component. */
+ dmnsn_specular *specular; /**< Specular component. */
dmnsn_reflection *reflection; /**< Reflection component. */
} dmnsn_finish;
@@ -169,18 +133,6 @@ typedef struct dmnsn_finish {
dmnsn_finish dmnsn_new_finish(void);
/**
- * Delete a finish.
- * @param[in,out] finish The finish to delete.
- */
-void dmnsn_delete_finish(dmnsn_finish finish);
-
-/**
- * Increment a finish's reference count.
- * @param[in,out] finish The finish to acquire.
- */
-void dmnsn_finish_incref(dmnsn_finish *finish);
-
-/**
* Fill missing finish properties from a default finish.
* @param[in] default_finish The default finish.
* @param[in,out] finish The finish to fill.
diff --git a/libdimension/dimension/finishes.h b/libdimension/dimension/finishes.h
index 7ed66d3..e1f7b44 100644
--- a/libdimension/dimension/finishes.h
+++ b/libdimension/dimension/finishes.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -25,25 +25,27 @@
/**
* Regular diffuse finish.
+ * @param[in] pool The memory pool to allocate from.
* @param[in] diffuse The diffuse reflection coefficient.
* @return A diffuse finish component.
*/
-dmnsn_diffuse *dmnsn_new_lambertian(double diffuse);
+dmnsn_diffuse *dmnsn_new_lambertian(dmnsn_pool *pool, double diffuse);
/**
* A phong specular highlight.
+ * @param[in] pool The memory pool to allocate from.
* @param[in] specular The specular reflection coefficient.
- * @param[in] exp The exponent (roughly the highlight size).
+ * @param[in] exp The exponent (roughly the highlight size).
* @return A phong specular finish component.
*/
-dmnsn_specular *dmnsn_new_phong(double specular, double exp);
+dmnsn_specular *dmnsn_new_phong(dmnsn_pool *pool, double specular, double exp);
/**
* Specular (mirror) reflection.
- * @param[in] min Reflection at paralell angles.
- * @param[in] max Reflection at perpendicular angles (often == \p min).
+ * @param[in] pool The memory pool to allocate from.
+ * @param[in] min Reflection at paralell angles.
+ * @param[in] max Reflection at perpendicular angles (often == \p min).
* @param[in] falloff Degree of exponential falloff (usually 1).
* @return A reflective finish component.
*/
-dmnsn_reflection *dmnsn_new_basic_reflection(dmnsn_color min, dmnsn_color max,
- double falloff);
+dmnsn_reflection *dmnsn_new_basic_reflection(dmnsn_pool *pool, dmnsn_color min, dmnsn_color max, double falloff);