summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-30 15:48:29 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-30 15:48:29 -0400
commit45e219eac23ea4a8181f68300fed693d9ac361a0 (patch)
tree06b72b3ca9a97b1352537836a2a42af7033ae6b1 /libdimension
parentf61c7c75c3c7ff4a329315700d3efa1d77bafa6d (diff)
downloaddimension-45e219eac23ea4a8181f68300fed693d9ac361a0.tar.xz
canvas: Use pool.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/canvas.c34
-rw-r--r--libdimension/canvas_pigment.c1
-rw-r--r--libdimension/dimension/canvas.h15
-rw-r--r--libdimension/dimension/gl.h16
-rw-r--r--libdimension/dimension/png.h28
-rw-r--r--libdimension/gl-stubs.c7
-rw-r--r--libdimension/gl.c17
-rw-r--r--libdimension/png-stubs.c6
-rw-r--r--libdimension/png.c16
-rw-r--r--libdimension/scene.c1
-rw-r--r--libdimension/tests/gl.c33
-rw-r--r--libdimension/tests/png.c47
-rw-r--r--libdimension/tests/render.c12
13 files changed, 112 insertions, 121 deletions
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 0242671..e290910 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -24,38 +24,36 @@
*/
#include "dimension-internal.h"
-#include <stdlib.h> /* For dmnsn_free() */
-/* Allocate a new canvas, of width x and height y */
+/** cleanup_fn for canvases. */
+static void dmnsn_canvas_cleanup(void *ptr);
+
dmnsn_canvas *
-dmnsn_new_canvas(size_t width, size_t height)
+dmnsn_new_canvas(dmnsn_pool *pool, size_t width, size_t height)
{
- dmnsn_canvas *canvas = DMNSN_MALLOC(dmnsn_canvas);
+ dmnsn_canvas *canvas = DMNSN_PALLOC_TIDY(pool, dmnsn_canvas, dmnsn_canvas_cleanup);
canvas->width = width;
canvas->height = height;
canvas->optimizers = dmnsn_new_array(sizeof(dmnsn_canvas_optimizer));
canvas->pixels = dmnsn_malloc(sizeof(dmnsn_tcolor)*width*height);
- DMNSN_REFCOUNT_INIT(canvas);
return canvas;
}
-/* Delete a dmnsn_canvas allocated with dmnsn_new_canvas */
void
-dmnsn_delete_canvas(dmnsn_canvas *canvas)
+dmnsn_canvas_cleanup(void *ptr)
{
- if (DMNSN_DECREF(canvas)) {
- /* Free the optimizers */
- DMNSN_ARRAY_FOREACH (dmnsn_canvas_optimizer *, i, canvas->optimizers) {
- if (i->free_fn) {
- i->free_fn(i->ptr);
- }
- }
- dmnsn_delete_array(canvas->optimizers);
+ dmnsn_canvas *canvas = ptr;
- /* Free the pixels and canvas */
- dmnsn_free(canvas->pixels);
- dmnsn_free(canvas);
+ /* Free the optimizers */
+ DMNSN_ARRAY_FOREACH (dmnsn_canvas_optimizer *, i, canvas->optimizers) {
+ if (i->free_fn) {
+ i->free_fn(i->ptr);
+ }
}
+ dmnsn_delete_array(canvas->optimizers);
+
+ /* Free the pixels and canvas */
+ dmnsn_free(canvas->pixels);
}
/* Set a canvas optimizer */
diff --git a/libdimension/canvas_pigment.c b/libdimension/canvas_pigment.c
index 85ae551..bc5653e 100644
--- a/libdimension/canvas_pigment.c
+++ b/libdimension/canvas_pigment.c
@@ -49,7 +49,6 @@ static void
dmnsn_canvas_pigment_free_fn(dmnsn_pigment *pigment)
{
dmnsn_canvas_pigment *canvas_pigment = (dmnsn_canvas_pigment *)pigment;
- dmnsn_delete_canvas(canvas_pigment->canvas);
dmnsn_free(canvas_pigment);
}
diff --git a/libdimension/dimension/canvas.h b/libdimension/dimension/canvas.h
index ba549ad..d03a37e 100644
--- a/libdimension/dimension/canvas.h
+++ b/libdimension/dimension/canvas.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -39,8 +39,6 @@ typedef struct dmnsn_canvas {
* at (a,b) is accessible as pixels[b*width + a].
*/
dmnsn_tcolor *pixels;
-
- DMNSN_REFCOUNT; /**< Reference count. */
} dmnsn_canvas;
/**
@@ -63,17 +61,12 @@ typedef struct dmnsn_canvas_optimizer {
/**
* Allocate a new canvas.
- * @param[in] width The width of the canvas to allocate (in pixels).
+ * @param[in] pool The memory pool to allocate from.
+ * @param[in] width The width of the canvas to allocate (in pixels).
* @param[in] height The height of the canvas to allocate (in pixels).
* @return The allocated canvas.
*/
-dmnsn_canvas *dmnsn_new_canvas(size_t width, size_t height);
-
-/**
- * Delete a canvas.
- * @param[in,out] canvas The canvas to delete.
- */
-void dmnsn_delete_canvas(dmnsn_canvas *canvas);
+dmnsn_canvas *dmnsn_new_canvas(dmnsn_pool *pool, size_t width, size_t height);
/**
* Set a canvas optimizer
diff --git a/libdimension/dimension/gl.h b/libdimension/dimension/gl.h
index e276228..8e64ba6 100644
--- a/libdimension/dimension/gl.h
+++ b/libdimension/dimension/gl.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2010 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -32,18 +32,16 @@ int dmnsn_gl_optimize_canvas(dmnsn_canvas *canvas);
/**
* Write canvas to GL framebuffer.
- * @param[in] canvas The canvas to write.
+ * @param[in] canvas The canvas to draw.
* @return 0 on success, non-zero on failure.
*/
int dmnsn_gl_write_canvas(const dmnsn_canvas *canvas);
/**
* Read a canvas from a GL framebuffer.
- * @param[in] x0 The \a x screen coordinate to start copying from.
- * @param[in] y0 The \a y screen coordinate to start copying from.
- * @param[in] width The width of the read area.
- * @param[in] height The height of the read area.
- * @return The allocated canvas, or NULL on failure.
+ * @param[in] canvas The canvas to write to.
+ * @param[in] x0 The \a x screen coordinate to start copying from.
+ * @param[in] y0 The \a y screen coordinate to start copying from.
+ * @return 0 on success, non-zero on failure.
*/
-dmnsn_canvas *dmnsn_gl_read_canvas(size_t x0, size_t y0,
- size_t width, size_t height);
+int dmnsn_gl_read_canvas(dmnsn_canvas *canvas, size_t x0, size_t y0);
diff --git a/libdimension/dimension/png.h b/libdimension/dimension/png.h
index 244c481..c45a9bf 100644
--- a/libdimension/dimension/png.h
+++ b/libdimension/dimension/png.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -20,7 +20,7 @@
/**
* @file
- * PNG import/export of canvases
+ * PNG import/export of canvases.
*/
#include <stdio.h>
@@ -34,16 +34,16 @@ int dmnsn_png_optimize_canvas(dmnsn_canvas *canvas);
/**
* Write a canvas to a file in PNG format.
- * @param[in] canvas The canvas to write.
- * @param[in,out] file The file to write to.
+ * @param[in] canvas The canvas to write.
+ * @param[in,out] file The file to write to.
* @return 0 on success, non-zero on failure.
*/
int dmnsn_png_write_canvas(const dmnsn_canvas *canvas, FILE *file);
/**
* Write a canvas to a PNG file in the background.
- * @param[in] canvas The canvas to write.
- * @param[in,out] file The file to write to.
+ * @param[in] canvas The canvas to write.
+ * @param[in,out] file The file to write to.
* @return A \ref dmnsn_future object, or NULL on failure.
*/
dmnsn_future *dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas,
@@ -51,18 +51,20 @@ dmnsn_future *dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas,
/**
* Read a canvas from a PNG file.
+ * @param[in] pool The memory pool to allocate from.
* @param[in,out] file The PNG file to read.
* @return The new canvas, or NULL on failure.
*/
-dmnsn_canvas *dmnsn_png_read_canvas(FILE *file);
+dmnsn_canvas *dmnsn_png_read_canvas(dmnsn_pool *pool, FILE *file);
/**
* Read a canvas from a PNG file in the background.
- * @param[out] canvas The address of a non-allocated canvas object. The
- * canvas object will be allocated and filled with the
- * contents of \p file. Do not read from this object
- * until the background task has finished.
- * @param[in,out] file The PNG file to read.
+ * @param[out] canvas The address of a non-allocated canvas object. The canvas
+ * object will be allocated and filled with the contents of
+ * \p file. Do not read from this object until the
+ * background task has finished.
+ * @param[in] pool The memory pool to allocate from.
+ * @param[in,out] file The PNG file to read.
* @return A \ref dmnsn_future object, or NULL on failure.
*/
-dmnsn_future *dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file);
+dmnsn_future *dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, dmnsn_pool *pool, FILE *file);
diff --git a/libdimension/gl-stubs.c b/libdimension/gl-stubs.c
index bf41d41..ca17056 100644
--- a/libdimension/gl-stubs.c
+++ b/libdimension/gl-stubs.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -40,9 +40,8 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
return -1;
}
-dmnsn_canvas *
-dmnsn_gl_read_canvas(size_t x0, size_t y0,
- size_t width, size_t height)
+int
+dmnsn_gl_read_canvas(dmnsn_canvas *canvas, size_t x0, size_t y0)
{
errno = ENOSYS;
return NULL;
diff --git a/libdimension/gl.c b/libdimension/gl.c
index 0b6b0b0..c6a2da5 100644
--- a/libdimension/gl.c
+++ b/libdimension/gl.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -77,21 +77,18 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
}
/* Read a canvas from a GL framebuffer. Returns NULL on failure. */
-dmnsn_canvas *
-dmnsn_gl_read_canvas(size_t x0, size_t y0,
- size_t width, size_t height)
+int
+dmnsn_gl_read_canvas(dmnsn_canvas *canvas, size_t x0, size_t y0)
{
- dmnsn_canvas *canvas = dmnsn_new_canvas(width, height);
+ size_t width = canvas->width;
+ size_t height = canvas->height;
/* Array of 16-bit ints in RGBA order */
GLushort *pixels = dmnsn_malloc(4*width*height*sizeof(GLushort));
-
glReadPixels(x0, y0, width, height, GL_RGBA, GL_UNSIGNED_SHORT, pixels);
-
if (glGetError() != GL_NO_ERROR) {
dmnsn_free(pixels);
- dmnsn_delete_canvas(canvas);
- return NULL;
+ return -1;
}
for (size_t y = 0; y < height; ++y) {
@@ -111,5 +108,5 @@ dmnsn_gl_read_canvas(size_t x0, size_t y0,
}
dmnsn_free(pixels);
- return canvas;
+ return 0;
}
diff --git a/libdimension/png-stubs.c b/libdimension/png-stubs.c
index b9a43ae..d68b543 100644
--- a/libdimension/png-stubs.c
+++ b/libdimension/png-stubs.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -48,14 +48,14 @@ dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas, FILE *file)
}
dmnsn_canvas *
-dmnsn_png_read_canvas(FILE *file)
+dmnsn_png_read_canvas(dmnsn_pool *pool, FILE *file)
{
errno = ENOSYS;
return NULL;
}
dmnsn_future *
-dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file)
+dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, dmnsn_pool *pool, FILE *file)
{
errno = ENOSYS;
return NULL;
diff --git a/libdimension/png.c b/libdimension/png.c
index c33ad91..8348e5f 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -49,6 +49,7 @@ typedef struct {
typedef struct {
dmnsn_future *future;
dmnsn_canvas **canvas;
+ dmnsn_pool *pool;
FILE *file;
} dmnsn_png_read_payload;
@@ -85,25 +86,26 @@ dmnsn_png_write_canvas_async(const dmnsn_canvas *canvas, FILE *file)
/* Read a canvas from the PNG file `file'. Return NULL on error. */
dmnsn_canvas *
-dmnsn_png_read_canvas(FILE *file)
+dmnsn_png_read_canvas(dmnsn_pool *pool, FILE *file)
{
dmnsn_canvas *canvas;
- dmnsn_future *future = dmnsn_png_read_canvas_async(&canvas, file);
+ dmnsn_future *future = dmnsn_png_read_canvas_async(&canvas, pool, file);
dmnsn_future_join(future);
return canvas;
}
/* Read a canvas from a png file in the background */
dmnsn_future *
-dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, FILE *file)
+dmnsn_png_read_canvas_async(dmnsn_canvas **canvas, dmnsn_pool *pool, FILE *file)
{
dmnsn_future *future = dmnsn_new_future();
dmnsn_png_read_payload *payload = DMNSN_MALLOC(dmnsn_png_read_payload);
- payload->future = future;
- payload->canvas = canvas;
+ payload->future = future;
+ payload->canvas = canvas;
*payload->canvas = NULL;
- payload->file = file;
+ payload->pool = pool;
+ payload->file = file;
/* Create the worker thread */
dmnsn_new_thread(future, dmnsn_png_read_canvas_thread, payload);
@@ -339,7 +341,7 @@ dmnsn_png_read_canvas_thread(void *ptr)
png_read_image(png_ptr, row_pointers);
/* Allocate the canvas */
- *payload->canvas = dmnsn_new_canvas(width, height);
+ *payload->canvas = dmnsn_new_canvas(payload->pool, width, height);
/* Now we convert the image to our canvas format. This depends on the image
bit depth (which has been scaled up to at least 8 or 16), and the presence
diff --git a/libdimension/scene.c b/libdimension/scene.c
index 2d25602..cc2ee98 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -66,7 +66,6 @@ dmnsn_delete_scene(dmnsn_scene *scene)
dmnsn_delete_array(scene->lights);
dmnsn_delete_array(scene->objects);
- dmnsn_delete_canvas(scene->canvas);
dmnsn_delete_camera(scene->camera);
dmnsn_delete_interior(scene->default_interior);
dmnsn_delete_texture(scene->default_texture);
diff --git a/libdimension/tests/gl.c b/libdimension/tests/gl.c
index 52b3256..c46eada 100644
--- a/libdimension/tests/gl.c
+++ b/libdimension/tests/gl.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -27,14 +27,8 @@ main(void)
dmnsn_die_on_warnings(true);
/* Allocate our canvas */
- dmnsn_canvas *canvas = dmnsn_new_canvas(768, 480);
-
- /* Optimize the canvas for GL drawing */
- if (dmnsn_gl_optimize_canvas(canvas) != 0) {
- dmnsn_delete_canvas(canvas);
- fprintf(stderr, "--- Couldn't optimize canvas for GL! ---\n");
- return EXIT_FAILURE;
- }
+ dmnsn_pool *pool = dmnsn_new_pool();
+ dmnsn_canvas *canvas = dmnsn_new_canvas(pool, 768, 480);
/* Paint the test pattern */
dmnsn_paint_test_canvas(canvas);
@@ -43,7 +37,7 @@ main(void)
dmnsn_display *display = dmnsn_new_display(canvas);
if (!display) {
fprintf(stderr, "--- WARNING: Couldn't initialize X or glX! ---\n");
- dmnsn_delete_canvas(canvas);
+ dmnsn_delete_pool(pool);
return EXIT_SUCCESS;
}
@@ -51,23 +45,28 @@ main(void)
printf("Drawing to OpenGL\n");
if (dmnsn_gl_write_canvas(canvas) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_canvas(canvas);
+ dmnsn_delete_pool(pool);
fprintf(stderr, "--- Drawing to OpenGL failed! ---\n");
return EXIT_FAILURE;
}
dmnsn_display_flush(display);
- dmnsn_delete_canvas(canvas);
/*
* Now test GL import/export
*/
+ /* Optimize the canvas for GL drawing */
+ if (dmnsn_gl_optimize_canvas(canvas) != 0) {
+ dmnsn_delete_pool(pool);
+ fprintf(stderr, "--- Couldn't optimize canvas for GL! ---\n");
+ return EXIT_FAILURE;
+ }
+
/* Read the image back from OpenGL */
printf("Reading from OpenGL\n");
- canvas = dmnsn_gl_read_canvas(0, 0, 768, 480);
- if (!canvas) {
+ if (dmnsn_gl_read_canvas(canvas, 0, 0) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_canvas(canvas);
+ dmnsn_delete_pool(pool);
fprintf(stderr, "--- Reading from OpenGL failed! ---\n");
return EXIT_FAILURE;
}
@@ -76,13 +75,13 @@ main(void)
printf("Drawing to OpenGL\n");
if (dmnsn_gl_write_canvas(canvas) != 0) {
dmnsn_delete_display(display);
- dmnsn_delete_canvas(canvas);
+ dmnsn_delete_pool(pool);
fprintf(stderr, "--- Drawing to OpenGL failed! ---\n");
return EXIT_FAILURE;
}
dmnsn_display_flush(display);
dmnsn_delete_display(display);
- dmnsn_delete_canvas(canvas);
+ dmnsn_delete_pool(pool);
return EXIT_SUCCESS;
}
diff --git a/libdimension/tests/png.c b/libdimension/tests/png.c
index 1bd418f..ed64b39 100644
--- a/libdimension/tests/png.c
+++ b/libdimension/tests/png.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2009-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2009-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -24,17 +24,20 @@
int
main(void)
{
+ int ret = EXIT_SUCCESS;
+
/* Treat warnings as errors for tests */
dmnsn_die_on_warnings(true);
/* Allocate our canvas */
- dmnsn_canvas *canvas = dmnsn_new_canvas(768, 480);
+ dmnsn_pool *pool = dmnsn_new_pool();
+ dmnsn_canvas *canvas = dmnsn_new_canvas(pool, 768, 480);
/* Optimize the canvas for PNG export */
if (dmnsn_png_optimize_canvas(canvas) != 0) {
- dmnsn_delete_canvas(canvas);
fprintf(stderr, "--- Couldn't optimize canvas for PNG! ---\n");
- return EXIT_FAILURE;
+ ret = EXIT_FAILURE;
+ goto exit;
}
/* Paint the test pattern */
@@ -45,20 +48,19 @@ main(void)
printf("Writing scene to PNG\n");
FILE *ofile = fopen("png1.png", "wb");
if (!ofile) {
- dmnsn_delete_canvas(canvas);
fprintf(stderr, "--- Couldn't open 'png1.png' for writing! ---\n");
- return EXIT_FAILURE;
+ ret = EXIT_FAILURE;
+ goto exit;
}
if (dmnsn_png_write_canvas(canvas, ofile) != 0) {
- fclose(ofile);
- dmnsn_delete_canvas(canvas);
fprintf(stderr, "--- Writing canvas to PNG failed! ---\n");
- return EXIT_FAILURE;
+ fclose(ofile);
+ ret = EXIT_FAILURE;
+ goto exit;
}
fclose(ofile);
- dmnsn_delete_canvas(canvas);
/*
* Now test PNG import/export
@@ -70,14 +72,16 @@ main(void)
FILE *ifile = fopen("png1.png", "rb");
if (!ifile) {
fprintf(stderr, "--- Couldn't open 'png1.png' for reading! ---\n");
- return EXIT_FAILURE;
+ ret = EXIT_FAILURE;
+ goto exit;
}
- canvas = dmnsn_png_read_canvas(ifile);
+ canvas = dmnsn_png_read_canvas(pool, ifile);
if (!canvas) {
- fclose(ifile);
fprintf(stderr, "--- Reading canvas from PNG failed! ---\n");
- return EXIT_FAILURE;
+ fclose(ifile);
+ ret = EXIT_FAILURE;
+ goto exit;
}
fclose(ifile);
@@ -88,19 +92,20 @@ main(void)
ofile = fopen("png2.png", "wb");
if (!ofile) {
fprintf(stderr, "--- Couldn't open 'png2.png' for writing! ---\n");
- dmnsn_delete_canvas(canvas);
- return EXIT_FAILURE;
+ ret = EXIT_FAILURE;
+ goto exit;
}
if (dmnsn_png_write_canvas(canvas, ofile) != 0) {
- fclose(ofile);
- dmnsn_delete_canvas(canvas);
fprintf(stderr, "--- Writing canvas to PNG failed! ---\n");
- return EXIT_FAILURE;
+ fclose(ofile);
+ ret = EXIT_FAILURE;
+ goto exit;
}
fclose(ofile);
- dmnsn_delete_canvas(canvas);
- return EXIT_SUCCESS;
+ exit:
+ dmnsn_delete_pool(pool);
+ return ret;
}
diff --git a/libdimension/tests/render.c b/libdimension/tests/render.c
index e68dcc4..f5ba685 100644
--- a/libdimension/tests/render.c
+++ b/libdimension/tests/render.c
@@ -36,9 +36,9 @@ dmnsn_test_scene_set_defaults(dmnsn_scene *scene)
}
static void
-dmnsn_test_scene_add_canvas(dmnsn_scene *scene)
+dmnsn_test_scene_add_canvas(dmnsn_pool *pool, dmnsn_scene *scene)
{
- scene->canvas = dmnsn_new_canvas(768, 480);
+ scene->canvas = dmnsn_new_canvas(pool, 768, 480);
}
static void
@@ -69,7 +69,7 @@ dmnsn_test_scene_add_camera(dmnsn_scene *scene)
}
static void
-dmnsn_test_scene_add_background(dmnsn_scene *scene)
+dmnsn_test_scene_add_background(dmnsn_pool *pool, dmnsn_scene *scene)
{
dmnsn_pattern *sky_gradient = dmnsn_new_gradient_pattern(dmnsn_y);
dmnsn_map *sky_gradient_pigment_map = dmnsn_new_pigment_map();
@@ -78,7 +78,7 @@ dmnsn_test_scene_add_background(dmnsn_scene *scene)
dmnsn_pigment *png_pigment;
FILE *png = fopen("png2.png", "rb");
if (png) {
- png_canvas = dmnsn_png_read_canvas(png);
+ png_canvas = dmnsn_png_read_canvas(pool, png);
fclose(png);
}
if (png_canvas) {
@@ -305,9 +305,9 @@ dmnsn_new_test_scene(dmnsn_pool *pool)
{
dmnsn_scene *scene = dmnsn_new_scene(pool);
dmnsn_test_scene_set_defaults(scene);
- dmnsn_test_scene_add_canvas(scene);
+ dmnsn_test_scene_add_canvas(pool, scene);
dmnsn_test_scene_add_camera(scene);
- dmnsn_test_scene_add_background(scene);
+ dmnsn_test_scene_add_background(pool, scene);
dmnsn_test_scene_add_lights(scene);
dmnsn_test_scene_add_objects(scene);
return scene;