]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/device.cpp
Use pointers directly from guile to C and viceversa
[guile-irrlicht.git] / src / device.cpp
index 0ecb69435ee3a9ce77b76248f9807ff0c7f47e2f..195ff5dcb13dbe301216f87fd27b67229346bb88 100644 (file)
@@ -31,6 +31,8 @@
 #include "wchar.h"
 #include "wrapped.h"
 
+using namespace irr;
+
 extern "C" {
 
   void
@@ -38,12 +40,13 @@ extern "C" {
   {
     init_device_type ();
     DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice);
+    DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0,
+                  irr_IrrlichtDevice_setWindowCaption);
     DEFINE_GSUBR ("get-timer", 1, 0, 0, irr_getTimer);
     DEFINE_GSUBR ("is-window-active?", 1, 0, 0, irr_isWindowActive);
     DEFINE_GSUBR ("run", 1, 0, 0, irr_run);
     DEFINE_GSUBR ("set-event-receiver!", 2, 0, 0, irr_setEventReceiver);
     DEFINE_GSUBR ("set-resizable!", 2, 0, 0, irr_setResizable);
-    DEFINE_GSUBR ("set-window-caption!", 2, 0, 0, irr_setWindowCaption);
     DEFINE_GSUBR ("yield", 1, 0, 0, irr_yield);
   }
 
@@ -60,17 +63,24 @@ extern "C" {
                     SCM vsync,
                     SCM receiver)
   {
-    UNWRAP (receiver);
-
-    irr::IrrlichtDevice* device =
-      irr::createDevice (scm_to_driver_type (device_type),
-                         scm_to_dimension2d_u32 (window_size),
-                         scm_to_uint32 (bits),
-                         scm_to_bool (fullscreen),
-                         scm_to_bool (stencilbuffer),
-                         scm_to_bool (vsync),
-                         UNWRAPPED (receiver));
-    return scm_from_pointer (device, NULL);
+    IrrlichtDevice* device =
+      createDevice (scm_to_driver_type (device_type),
+                    scm_to_dimension2d_u32 (window_size),
+                    scm_to_uint32 (bits),
+                    scm_to_bool (fullscreen),
+                    scm_to_bool (stencilbuffer),
+                    scm_to_bool (vsync),
+                    (IEventReceiver*)scm_to_pointer (receiver));
+    return scm_from_pointer ((void*)device, NULL);
+  }
+
+  SCM
+  irr_IrrlichtDevice_setWindowCaption (SCM device,
+                                       SCM text)
+  {
+    ((IrrlichtDevice*)scm_to_pointer (device))->
+      setWindowCaption (scm_to_wide_char_string (text));
+    return SCM_UNSPECIFIED;
   }
 
   SCM
@@ -112,15 +122,6 @@ extern "C" {
     return SCM_UNSPECIFIED;
   }
 
-  SCM
-  irr_setWindowCaption (SCM wrapped_device,
-                        SCM text)
-  {
-    irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
-    device->setWindowCaption (scm_to_wide_char_string (text));
-    return SCM_UNSPECIFIED;
-  }
-
   SCM
   irr_yield (SCM wrapped_device)
   {