+/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
+
+ Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
+
+ This file is part of guile-irrlicht.
+
+ guile-irrlicht is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 3 of the
+ License, or (at your option) any later version.
+
+ guile-irrlicht 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 Lesser General Public
+ License along with guile-irrlicht. If not, see
+ <http://www.gnu.org/licenses/>.
+*/
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+#include "primitive-types.h"
+
+extern "C" {
+
+ irr::scene::E_PRIMITIVE_TYPE
+ scm_to_primitive_type (SCM primitive_type)
+ {
+ char* type = scm_to_utf8_stringn (scm_symbol_to_string (primitive_type), NULL);
+ if (!strcmp (type, "points"))
+ {
+ return irr::scene::EPT_POINTS;
+ }
+ else if (!strcmp (type, "line-strip"))
+ {
+ return irr::scene::EPT_LINE_STRIP;
+ }
+ else if (!strcmp (type, "line-loop"))
+ {
+ return irr::scene::EPT_LINE_LOOP;
+ }
+ else if (!strcmp (type, "lines"))
+ {
+ return irr::scene::EPT_LINES;
+ }
+ else if (!strcmp (type, "triangle-strip"))
+ {
+ return irr::scene::EPT_TRIANGLE_STRIP;
+ }
+ else if (!strcmp (type, "triangle-fan"))
+ {
+ return irr::scene::EPT_TRIANGLE_FAN;
+ }
+ else if (!strcmp (type, "triangles"))
+ {
+ return irr::scene::EPT_TRIANGLES;
+ }
+ else if (!strcmp (type, "quad-strip"))
+ {
+ return irr::scene::EPT_QUAD_STRIP;
+ }
+ else if (!strcmp (type, "quads"))
+ {
+ return irr::scene::EPT_QUADS;
+ }
+ else if (!strcmp (type, "polygon"))
+ {
+ return irr::scene::EPT_POLYGON;
+ }
+ else if (!strcmp (type, "point-sprites"))
+ {
+ return irr::scene::EPT_POINT_SPRITES;
+ }
+ else
+ {
+ scm_error (scm_arg_type_key, NULL, "Wrong primitive type: ~S",
+ scm_list_1 (primitive_type), scm_list_1 (primitive_type));
+ }
+ }
+
+}