]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/vertex3d.cpp
make-vertex3d
[guile-irrlicht.git] / src / vertex3d.cpp
diff --git a/src/vertex3d.cpp b/src/vertex3d.cpp
new file mode 100644 (file)
index 0000000..07a85b9
--- /dev/null
@@ -0,0 +1,58 @@
+/* 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 "color.h"
+#include "vector2d.h"
+#include "vector3d.h"
+#include "vertex3d.h"
+#include "wrapped.h"
+
+extern "C" {
+
+  void
+  init_vertex3d (void)
+  {
+    init_vertex3d_type ();
+    scm_c_define_gsubr ("make-vertex3d", 4, 0, 0, (scm_t_subr)make_vertex3d);
+    scm_c_export ("make-vertex3d", NULL);
+  }
+
+  DEFINE_WRAPPED_TYPE (irr::video::S3DVertex*, "vertex3d",
+                       init_vertex3d_type, vertex3d_p,
+                       wrap_vertex3d, unwrap_vertex3d);
+
+  SCM
+  make_vertex3d (SCM position,
+                 SCM normal,
+                 SCM color,
+                 SCM tcoords)
+  {
+    irr::video::S3DVertex* vertex =
+      new irr::video::S3DVertex (scm_to_vector3df (position),
+                                 scm_to_vector3df (normal),
+                                 scm_to_color (color),
+                                 scm_to_vector2df (tcoords));
+    return wrap_vertex3d (vertex);
+  }
+
+}