diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-07-16 01:16:09 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-07-16 01:16:09 +0000 |
commit | 8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021 (patch) | |
tree | 4092a281882e34ac53ec15d582dcbf2cb0d408c0 /libdimension/dimension | |
parent | 1928016fe7aa439d4bfb61d3a7e7b7399ca7a229 (diff) | |
download | dimension-8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021.tar.xz |
Add destructor callbacks for polymorphic C types, and use their base
dmnsn_delete_*() function.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r-- | libdimension/dimension/camera.h | 13 | ||||
-rw-r--r-- | libdimension/dimension/cameras.h | 1 | ||||
-rw-r--r-- | libdimension/dimension/canvas.h | 6 | ||||
-rw-r--r-- | libdimension/dimension/object.h | 5 | ||||
-rw-r--r-- | libdimension/dimension/objects.h | 2 | ||||
-rw-r--r-- | libdimension/dimension/pigments.h | 1 | ||||
-rw-r--r-- | libdimension/dimension/texture.h | 4 |
7 files changed, 17 insertions, 15 deletions
diff --git a/libdimension/dimension/camera.h b/libdimension/dimension/camera.h index 13c03b0..3e6da4f 100644 --- a/libdimension/dimension/camera.h +++ b/libdimension/dimension/camera.h @@ -34,20 +34,15 @@ typedef dmnsn_line dmnsn_camera_ray_fn(const dmnsn_camera *camera, unsigned int x, unsigned int y); struct dmnsn_camera { + /* Callback functions */ + dmnsn_camera_ray_fn *ray_fn; + dmnsn_free_fn *free_fn; + /* Generic pointer for camera info */ void *ptr; - - /* Callback function */ - dmnsn_camera_ray_fn *ray_fn; }; dmnsn_camera *dmnsn_new_camera(); void dmnsn_delete_camera(dmnsn_camera *camera); -/* A perspective camera, at the origin, looking at (0, 0, 1). The feild of view - is the section of the plane z = 1 from (-0.5, -0.5) to (0.5, 0.5). Rays are - transformed by the transformation matrix `trans'. */ -dmnsn_camera *dmnsn_new_perspective_camera(dmnsn_matrix trans); -void dmnsn_delete_perspective_camera(dmnsn_camera *camera); - #endif /* DIMENSION_CAMERA_H */ diff --git a/libdimension/dimension/cameras.h b/libdimension/dimension/cameras.h index 1793bbd..b135693 100644 --- a/libdimension/dimension/cameras.h +++ b/libdimension/dimension/cameras.h @@ -29,7 +29,6 @@ is the section of the plane z = 1 from (-0.5, -0.5) to (0.5, 0.5). Rays are transformed by the transformation matrix `trans'. */ dmnsn_camera *dmnsn_new_perspective_camera(dmnsn_matrix trans); -void dmnsn_delete_perspective_camera(dmnsn_camera *camera); /* Get or set the transformation matrix */ dmnsn_matrix dmnsn_get_perspective_camera_trans(const dmnsn_camera *camera); diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h index 05a9a62..0d37acf 100644 --- a/libdimension/dimension/canvas.h +++ b/libdimension/dimension/canvas.h @@ -47,12 +47,14 @@ typedef struct dmnsn_canvas_optimizer dmnsn_canvas_optimizer; typedef void dmnsn_canvas_optimizer_fn(dmnsn_canvas *canvas, dmnsn_canvas_optimizer optimizer, unsigned int x, unsigned int y); -typedef void dmnsn_canvas_optimizer_free_fn(void *ptr); /* Canvas optimizer */ struct dmnsn_canvas_optimizer { + /* Callback types */ dmnsn_canvas_optimizer_fn *optimizer_fn; - dmnsn_canvas_optimizer_free_fn *free_fn; + dmnsn_free_fn *free_fn; + + /* Generic pointer */ void *ptr; }; diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h index 2da3ac7..901b366 100644 --- a/libdimension/dimension/object.h +++ b/libdimension/dimension/object.h @@ -34,7 +34,9 @@ typedef dmnsn_array *dmnsn_object_intersections_fn(const dmnsn_object *object, typedef int dmnsn_object_inside_fn(const dmnsn_object *object, dmnsn_vector point); +/* dmnsn_object definition */ struct dmnsn_object { + /* Surface properties */ dmnsn_texture *texture; /* Transformation matrix */ @@ -43,6 +45,7 @@ struct dmnsn_object { /* Callback functions */ dmnsn_object_intersections_fn *intersections_fn; dmnsn_object_inside_fn *inside_fn; + dmnsn_free_fn *free_fn; /* Generic pointer for object info */ void *ptr; @@ -50,6 +53,8 @@ struct dmnsn_object { /* Allocate a dummy object */ dmnsn_object *dmnsn_new_object(); + +/* Free an object */ void dmnsn_delete_object(dmnsn_object *object); #endif /* DIMENSION_OBJECT_H */ diff --git a/libdimension/dimension/objects.h b/libdimension/dimension/objects.h index d8c4144..4a24ca7 100644 --- a/libdimension/dimension/objects.h +++ b/libdimension/dimension/objects.h @@ -27,10 +27,8 @@ /* A sphere object, of radius 1, centered at the origin. */ dmnsn_object *dmnsn_new_sphere(); -void dmnsn_delete_sphere(dmnsn_object *sphere); /* A cube, axis-aligned, from (-1, -1, -1) to (1, 1, 1) */ dmnsn_object *dmnsn_new_cube(); -void dmnsn_delete_cube(dmnsn_object *cube); #endif /* DIMENSION_OBJECTS_H */ diff --git a/libdimension/dimension/pigments.h b/libdimension/dimension/pigments.h index ed0c3b2..61d50d8 100644 --- a/libdimension/dimension/pigments.h +++ b/libdimension/dimension/pigments.h @@ -27,6 +27,5 @@ /* A solid color */ dmnsn_pigment *dmnsn_new_solid_pigment(dmnsn_color color); -void dmnsn_delete_solid_pigment(dmnsn_pigment *pigment); #endif /* DIMENSION_PIGMENTS_H */ diff --git a/libdimension/dimension/texture.h b/libdimension/dimension/texture.h index 2eabe84..c26e840 100644 --- a/libdimension/dimension/texture.h +++ b/libdimension/dimension/texture.h @@ -38,7 +38,11 @@ typedef dmnsn_color dmnsn_pigment_fn(const dmnsn_pigment *pigment, /* dmnsn_pigment definition */ struct dmnsn_pigment { + /* Callbacks */ dmnsn_pigment_fn *pigment_fn; + dmnsn_free_fn *free_fn; + + /* Generic pointer */ void *ptr; }; |