summaryrefslogtreecommitdiffstats
path: root/libdimension/scene.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdimension/scene.c')
-rw-r--r--libdimension/scene.c37
1 files changed, 14 insertions, 23 deletions
diff --git a/libdimension/scene.c b/libdimension/scene.c
index 4595afd..dbda90b 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -20,37 +20,28 @@
#include "dimension.h"
#include <errno.h>
-#include <stdlib.h> /* For malloc */
#include <unistd.h> /* For sysconf */
/* Allocate an empty scene */
dmnsn_scene *
dmnsn_new_scene()
{
- dmnsn_scene *scene = malloc(sizeof(dmnsn_scene));
- if (scene) {
- scene->default_texture = dmnsn_new_texture();
- if (!scene->default_texture) {
- dmnsn_delete_scene(scene);
- errno = ENOMEM;
- return NULL;
- }
+ dmnsn_scene *scene = dmnsn_malloc(sizeof(dmnsn_scene));
- scene->camera = NULL;
- scene->canvas = NULL;
- scene->objects = dmnsn_new_array(sizeof(dmnsn_object *));
- scene->lights = dmnsn_new_array(sizeof(dmnsn_light *));
- scene->quality = DMNSN_RENDER_FULL;
- scene->reclimit = 5;
+ scene->default_texture = dmnsn_new_texture();
+ scene->camera = NULL;
+ scene->canvas = NULL;
+ scene->objects = dmnsn_new_array(sizeof(dmnsn_object *));
+ scene->lights = dmnsn_new_array(sizeof(dmnsn_light *));
+ scene->quality = DMNSN_RENDER_FULL;
+ scene->reclimit = 5;
+
+ /* Find the number of processors/cores running (TODO: do this portably) */
+ int nprocs = sysconf(_SC_NPROCESSORS_ONLN);
+ if (nprocs < 1)
+ nprocs = 1;
+ scene->nthreads = nprocs;
- /* Find the number of processors/cores running (TODO: do this portably) */
- int nprocs = sysconf(_SC_NPROCESSORS_ONLN);
- if (nprocs < 1)
- nprocs = 1;
- scene->nthreads = nprocs;
- } else {
- errno = ENOMEM;
- }
return scene;
}