commit b4d0c653d6d4256757a88649f8e5961257cc92c5
parent 3cec628d24c852b0b28ce9f453ae7c3a7f56ee31
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 4 Jan 2017 10:01:51 +0100
Begin the implementation of the solstice_run function
Diffstat:
5 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -82,6 +82,7 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(SOLSTICE_FILES_SRC
solstice.c
solstice_args.c
+ solstice_draw.c
solstice_entity.c
solstice_material.c
solstice_object.c)
diff --git a/src/solstice.c b/src/solstice.c
@@ -14,6 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "solstice.h"
+#include "solstice_c.h"
#include "solstice_args.h"
#include "parser/solparser.h"
@@ -250,3 +251,14 @@ solstice_release(struct solstice* solstice)
htable_object_release(&solstice->objects);
}
+res_T
+solstice_run(struct solstice* solstice)
+{
+ ASSERT(solstice);
+ if(solstice->framebuffer) { /* Rendering */
+ return solstice_draw(solstice);
+ } else { /* Solstice integration */
+ /* TODO */
+ return RES_OK;
+ }
+}
diff --git a/src/solstice.h b/src/solstice.h
@@ -78,5 +78,9 @@ extern LOCAL_SYM void
solstice_release
(struct solstice* solstice);
+extern LOCAL_SYM res_T
+solstice_run
+ (struct solstice* solstice);
+
#endif /* SOLSTICE_H */
diff --git a/src/solstice_c.h b/src/solstice_c.h
@@ -22,6 +22,10 @@
struct ssol_instance;
extern LOCAL_SYM res_T
+solstice_draw
+ (struct solstice* solstice);
+
+extern LOCAL_SYM res_T
solstice_setup_entities
(struct solstice* solstice);
diff --git a/src/solstice_draw.c b/src/solstice_draw.c
@@ -0,0 +1,43 @@
+/* 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include "solstice_c.h"
+
+#include <solstice/ssol.h>
+
+/*******************************************************************************
+ * Local functions
+ ******************************************************************************/
+res_T
+solstice_draw(struct solstice* solstice)
+{
+ struct ssol_image_layout layout;
+ res_T res = RES_OK;
+ ASSERT(solstice);
+
+ SSOL(image_get_layout(solstice->framebuffer, &layout));
+
+ res = ssol_draw(solstice->scene, solstice->camera, layout.width,
+ layout.height, ssol_image_write, solstice->framebuffer);
+ if(res != RES_OK) {
+ fprintf(stderr, "Rendering error\n");
+ goto error;
+ }
+
+exit:
+ return res;
+error:
+ goto exit;
+}