summaryrefslogtreecommitdiffstats
path: root/libdimension/cameras.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-08 17:12:02 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-08 17:12:02 +0000
commitbff7f2b3b440c30d0d6eb692576af57ef42edd1b (patch)
tree0ba45051db1ee7b7808339cfb587f8f76d8c7c5c /libdimension/cameras.c
parent14c9cd86e1b7c6ff27c5000d72721c54a718daac (diff)
downloaddimension-bff7f2b3b440c30d0d6eb692576af57ef42edd1b.tar.xz
Comments and style adjustments, and a couple fixes.
Diffstat (limited to 'libdimension/cameras.c')
-rw-r--r--libdimension/cameras.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libdimension/cameras.c b/libdimension/cameras.c
index f346bbc..29d1df4 100644
--- a/libdimension/cameras.c
+++ b/libdimension/cameras.c
@@ -36,16 +36,19 @@ static dmnsn_line dmnsn_perspective_camera_ray_fn(const dmnsn_camera *camera,
dmnsn_camera *
dmnsn_new_perspective_camera(dmnsn_matrix trans)
{
+ dmnsn_matrix *ptr;
dmnsn_camera *camera = dmnsn_new_camera();
if (camera) {
camera->ray_fn = &dmnsn_perspective_camera_ray_fn;
- camera->ptr = malloc(sizeof(dmnsn_matrix));
- if (!camera->ptr) {
+ /* Allocate room for the transformation matrix */
+ ptr = malloc(sizeof(dmnsn_matrix));
+ if (!ptr) {
dmnsn_delete_camera(camera);
return NULL;
}
- *((dmnsn_matrix*)camera->ptr) = trans;
+ *ptr = trans;
+ camera->ptr = ptr;
}
return camera;
}