]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/IVideoDriver.cpp
get-video-driver
[guile-irrlicht.git] / src / IVideoDriver.cpp
diff --git a/src/IVideoDriver.cpp b/src/IVideoDriver.cpp
new file mode 100644 (file)
index 0000000..6f19e9f
--- /dev/null
@@ -0,0 +1,63 @@
+/* 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 "IVideoDriver.h"
+
+extern "C" {
+
+  void
+  init_video_driver (void)
+  {
+    init_video_driver_type ();
+  }
+
+  static SCM video_driver_type;
+
+  void
+  init_video_driver_type (void)
+  {
+    SCM name, slots;
+    scm_t_struct_finalize finalizer;
+
+    name = scm_from_utf8_symbol ("video-driver");
+    slots = scm_list_1 (scm_from_utf8_symbol ("data"));
+    finalizer = NULL;
+
+    video_driver_type =
+      scm_make_foreign_object_type (name, slots, finalizer);
+  }
+
+  SCM
+  wrap_video_driver (irr::video::IVideoDriver* driver)
+  {
+    return scm_make_foreign_object_1 (video_driver_type, driver);
+  }
+
+  irr::video::IVideoDriver*
+  unwrap_video_driver (SCM driver_obj)
+  {
+    scm_assert_foreign_object_type (video_driver_type, driver_obj);
+    return (irr::video::IVideoDriver*)scm_foreign_object_ref (driver_obj, 0);
+  }
+
+}