From 0f0b704144bddc045657f7ed852b49d5e349b0bd Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 21 May 2011 20:27:09 -0600 Subject: Add refcounts to cameras. --- libdimension/dimension/camera.h | 5 +++-- libdimension/dimension/refcount.h | 3 +++ libdimension/dimension/scene.h | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/camera.h b/libdimension/dimension/camera.h index c3ad65b..67fffc0 100644 --- a/libdimension/dimension/camera.h +++ b/libdimension/dimension/camera.h @@ -44,8 +44,9 @@ struct dmnsn_camera { dmnsn_matrix trans; /**< Transformation matrix. */ - /** Generic pointer for camera info. */ - void *ptr; + void *ptr; /**< @internal Generic pointer for camera info. */ + + dmnsn_refcount *refcount; /**< @internal reference count. */ }; /** diff --git a/libdimension/dimension/refcount.h b/libdimension/dimension/refcount.h index 14f31ab..9d2c304 100644 --- a/libdimension/dimension/refcount.h +++ b/libdimension/dimension/refcount.h @@ -30,6 +30,7 @@ #define DMNSN_INCREF(obj) ((void)++(*(obj)->refcount)) /** + * @internal * Decrement a reference count. * @param[in,out] object The reference-counted object to release. * @return Whether the object is now garbage. @@ -42,6 +43,7 @@ typedef unsigned int dmnsn_refcount; /** + * @internal * Create a reference count. * @return A new reference counter, initialized to zero (a "borrowed" reference, * which will be garbage-collected the first time it is deleted). @@ -49,6 +51,7 @@ typedef unsigned int dmnsn_refcount; dmnsn_refcount *dmnsn_new_refcount(void); /** + * @internal * Delete a reference count. Raises an error if the reference count wasn't * zero. */ diff --git a/libdimension/dimension/scene.h b/libdimension/dimension/scene.h index ffe5fb3..b726a77 100644 --- a/libdimension/dimension/scene.h +++ b/libdimension/dimension/scene.h @@ -99,6 +99,13 @@ void dmnsn_initialize_scene(dmnsn_scene *scene); */ void dmnsn_scene_set_canvas(dmnsn_scene *scene, dmnsn_canvas *canvas); +/** + * Set the camera for a scene. + * @param[in,out] scene The scene for which to set the canvas. + * @param[in] camera The camera to set. + */ +void dmnsn_scene_set_camera(dmnsn_scene *scene, dmnsn_camera *camera); + /** * Add an object to a scene. * @param[in,out] scene The scene to which to add the object. -- cgit v1.2.3