From 836d8f7138633517c6e503520f7be354ac32d836 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 13 Jun 2009 22:55:48 +0000 Subject: Properly forward-declare dmnsn_object and dmnsn_camera, and take a transformation matrix in dmnsn_new_perspective_camera(). --- libdimension/dimension/camera.h | 16 +++++++++++----- libdimension/dimension/object.h | 8 ++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/camera.h b/libdimension/dimension/camera.h index b1c4ebe..4ea1cbe 100644 --- a/libdimension/dimension/camera.h +++ b/libdimension/dimension/camera.h @@ -25,23 +25,29 @@ * A camera. */ -typedef dmnsn_line dmnsn_camera_ray_fn(const dmnsn_canvas *canvas, +/* Forward-declare dmnsn_camera */ +typedef struct dmnsn_camera dmnsn_camera; + +/* Camera callback types */ +typedef dmnsn_line dmnsn_camera_ray_fn(const dmnsn_camera *camera, + const dmnsn_canvas *canvas, unsigned int x, unsigned int y); -typedef struct { +struct dmnsn_camera { /* Generic pointer for camera info */ void *ptr; /* Callback function */ dmnsn_camera_ray_fn *ray_fn; -} dmnsn_camera; +}; dmnsn_camera *dmnsn_new_camera(); void dmnsn_delete_camera(dmnsn_camera *camera); -/* A perspective camera, at the origin, looking at (0, 0, 1) */ +/* A perspective camera, at the origin, looking at (0, 0, 1). Rays are + transformed by the transformation matrix `trans'. */ -dmnsn_camera *dmnsn_new_perspective_camera(); +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/object.h b/libdimension/dimension/object.h index b9702f4..bd660a0 100644 --- a/libdimension/dimension/object.h +++ b/libdimension/dimension/object.h @@ -25,19 +25,23 @@ * Objects. */ +/* Forward-declare dmnsn_object */ +typedef struct dmnsn_object dmnsn_object; + +/* Object callback types */ typedef dmnsn_array *dmnsn_object_intersections_fn(const dmnsn_object *object, dmnsn_line line); typedef int dmnsn_object_inside_fn(const dmnsn_object *object, dmnsn_vector point); -typedef struct { +struct dmnsn_object { /* Generic pointer for object info */ void *ptr; /* Callback functions */ dmnsn_object_intersections_fn *intersections_fn; dmnsn_object_inside_fn *inside_fn; -} dmnsn_object; +}; dmnsn_object *dmnsn_new_object(); void dmnsn_delete_object(dmnsn_object *object); -- cgit v1.2.3