commit 11afdc28e796791ea883f2e7c8295367c9f8c872
parent cda569edf64c3f5aa8ba48d9882359757ea05902
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Jan 2017 11:16:02 +0100
Invoke the setup of the entities on Solstice init
Diffstat:
9 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -103,8 +103,8 @@ endif()
add_library(sollib STATIC ${SOLSTICE_FILES_SRC} ${SOLSTICE_FILES_INC})
add_executable(solstice ${SOLSTICE_SOURCE_DIR}/main.c)
-target_link_libraries(solstice
- LibYAML RSys ${MATH_LIB} sollib solparser SolAnim SolSolver)
+target_link_libraries(solstice ${MATH_LIB}
+ LibYAML RSys sollib solparser solstice-core SolAnim SolSolver Star3DUT)
set_target_properties(solstice PROPERTIES
VERSION ${VERSION}
SOVERSION ${VERSION_MAJOR})
diff --git a/src/core/solstice_core.h b/src/core/solstice_core.h
@@ -43,7 +43,6 @@ extern LOCAL_SYM res_T
score_device_create
(struct logger* logger, /* May be NULL <=> use default logger */
struct mem_allocator* allocator, /* May be NULL <=> use default allocator */
- const unsigned nthreads_hint, /* Hint on the number of threads to use */
const int verbose, /* Make the library more verbose */
struct score_device** dev);
diff --git a/src/core/solstice_core_device.c b/src/core/solstice_core_device.c
@@ -60,7 +60,6 @@ res_T
score_device_create
(struct logger* logger,
struct mem_allocator* mem_allocator,
- const unsigned nthreads_hint,
const int verbose,
struct score_device** out_dev)
{
@@ -68,7 +67,7 @@ score_device_create
struct mem_allocator* allocator;
res_T res = RES_OK;
- ASSERT(nthreads_hint && out_dev);
+ ASSERT(out_dev);
allocator = mem_allocator ? mem_allocator : &mem_default_allocator;
dev = MEM_CALLOC(allocator, 1, sizeof(struct score_device));
diff --git a/src/main.c b/src/main.c
@@ -30,11 +30,15 @@ main(int argc, char** argv)
res = solstice_args_init(&args, argc, argv);
if(res != RES_OK) goto error;
+ if(args.quit) goto exit;
res = solstice_init(NULL, &args, &solstice);
if(res != RES_OK) goto error;
solstice_is_init = 1;
+ res = solstice_run(&solstice);
+ if(res != RES_OK) goto error;
+
exit:
if(solstice_is_init) solstice_release(&solstice);
solstice_args_release(&args);
diff --git a/src/solstice.c b/src/solstice.c
@@ -17,6 +17,7 @@
#include "solstice_c.h"
#include "solstice_args.h"
#include "parser/solparser.h"
+#include "core/solstice_core.h"
#include <solstice/ssol.h>
@@ -175,6 +176,12 @@ load_data(struct solstice* solstice, const struct solstice_args* args)
res = solparser_load(solstice->parser);
if(res != RES_OK) goto error;
+ res = solstice_setup_entities(solstice);
+ if(res != RES_OK) {
+ fprintf(stderr, "Could not setup the Solstice entities.\n");
+ goto error;
+ }
+
exit:
if(file && file != stdin) fclose(file);
return res;
@@ -219,6 +226,12 @@ solstice_init
goto error;
}
+ res = score_device_create(NULL, allocator, 1/*verbose*/, &solstice->score);
+ if(res != RES_OK) {
+ fprintf(stderr, "Could not create the Solstice Core device.\n");
+ goto error;
+ }
+
if(args->rendering) {
res = setup_camera(solstice, args);
if(res != RES_OK) goto error;
@@ -226,6 +239,18 @@ solstice_init
if(res != RES_OK) goto error;
}
+ if(!args->output_filename) {
+ solstice->output = stdout;
+ } else {
+ solstice->output = fopen(args->output_filename, "w+");
+ if(!solstice->output) {
+ fprintf(stderr, "Could not open the output file `%s'.\n",
+ args->output_filename);
+ res = RES_IO_ERR;
+ goto error;
+ }
+ }
+
res = load_data(solstice, args);
if(res != RES_OK) goto error;
@@ -245,8 +270,10 @@ solstice_release(struct solstice* solstice)
if(solstice->ssol) SSOL(device_ref_put(solstice->ssol));
if(solstice->scene) SSOL(scene_ref_put(solstice->scene));
if(solstice->parser) solparser_ref_put(solstice->parser);
+ if(solstice->score) score_device_ref_put(solstice->score);
if(solstice->camera) SSOL(camera_ref_put(solstice->camera));
if(solstice->framebuffer) SSOL(image_ref_put(solstice->framebuffer));
+ if(solstice->output && solstice->output != stdout) fclose(solstice->output);
htable_material_release(&solstice->materials);
htable_object_release(&solstice->objects);
}
diff --git a/src/solstice.h b/src/solstice.h
@@ -65,6 +65,8 @@ struct solstice {
struct ssol_camera* camera;
struct ssol_image* framebuffer;
+ FILE* output; /* Output stream */
+
struct mem_allocator* allocator;
};
diff --git a/src/solstice_args.c b/src/solstice_args.c
@@ -247,6 +247,7 @@ solstice_args_init(struct solstice_args* args, const int argc, char** argv)
case 'h':
print_help(argv[0]);
solstice_args_release(args);
+ args->quit = 1;
goto exit;
case 'n':
res = cstr_to_ulong(optarg, &args->nrealisations);
diff --git a/src/solstice_args.h.in b/src/solstice_args.h.in
@@ -1,4 +1,4 @@
-/* Copyright (C) CNRS 2016
+/* Copyright (C) CNRS 2016-2017
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ struct solstice_args {
int rendering;
int quiet;
+ int quit; /* Quit the application */
};
#define SOLSTICE_ARGS_NULL__ {0}
@@ -60,7 +61,8 @@ static const struct solstice_args SOLSTICE_ARGS_NULL = SOLSTICE_ARGS_NULL__;
}, \
\
0, /* Rendering */ \
- 0 /* Quiet */ \
+ 0, /* Quiet */ \
+ 0 /* Quit */ \
}
static const struct solstice_args SOLSTICE_ARGS_DEFAULT =
SOLSTICE_ARGS_DEFAULT__;
diff --git a/src/solstice_entity.c b/src/solstice_entity.c
@@ -181,7 +181,7 @@ solstice_setup_entities
ASSERT(solstice && solstice->parser && solstice->score);
/* Release possible previous roots (incomplete, TODO) */
- score_scene_clear(solstice->score);
+ /*score_scene_clear(solstice->score);*/
/* (re) create the list of roots from entities */
solparser_entity_iterator_begin(solstice->parser, &it);