]> git.jsancho.org Git - guile-irrlicht.git/blobdiff - src/video-driver.cpp
set-transform! get-absolute-transformation
[guile-irrlicht.git] / src / video-driver.cpp
index ee80c369e767641caccb23b41e44b48c23e4e1d6..aa63e5289e45d298007d83ad5337d09e1bb5d543 100644 (file)
@@ -25,6 +25,8 @@
 #include "color.h"
 #include "device.h"
 #include "gui-environment.h"
+#include "material.h"
+#include "matrix4.h"
 #include "rect.h"
 #include "scene-manager.h"
 #include "texture.h"
@@ -42,8 +44,9 @@ extern "C" {
     scm_c_define_gsubr ("get-fps", 1, 0, 0, (scm_t_subr)irr_video_getFPS);
     scm_c_define_gsubr ("get-texture", 2, 0, 0, (scm_t_subr)irr_video_getTexture);
     scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver);
+    scm_c_define_gsubr ("set-transform!", 3, 0, 0, (scm_t_subr)irr_video_setTransform);
     scm_c_export ("begin-scene", "end-scene", "get-fps", "get-texture",
-                  "get-video-driver", NULL);
+                  "get-video-driver", "set-transform!", NULL);
   }
 
   DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver",
@@ -108,6 +111,26 @@ extern "C" {
     return wrap_texture (texture);
   }
 
+  SCM
+  irr_video_setMaterial (SCM wrapped_video_driver,
+                         SCM material)
+  {
+    irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+    driver->setMaterial (*(unwrap_material (material)));
+    return SCM_UNSPECIFIED;
+  }
+
+  SCM
+  irr_video_setTransform (SCM wrapped_video_driver,
+                          SCM state,
+                          SCM mat)
+  {
+    irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+    driver->setTransform (scm_to_transformation_state (state),
+                          scm_to_matrix4 (mat));
+    return SCM_UNSPECIFIED;
+  }
+
   SCM
   irr_getVideoDriver (SCM wrapped_obj)
   {
@@ -124,4 +147,43 @@ extern "C" {
     return wrap_video_driver (driver);
   }
 
+  irr::video::E_TRANSFORMATION_STATE
+  scm_to_transformation_state (SCM transformation_state)
+  {
+    char* state = scm_to_utf8_stringn (scm_symbol_to_string (transformation_state), NULL);
+    if (!strcmp (state, "view"))
+      {
+        return irr::video::ETS_VIEW;
+      }
+    else if (!strcmp (state, "world"))
+      {
+        return irr::video::ETS_WORLD;
+      }
+    else if (!strcmp (state, "projection"))
+      {
+        return irr::video::ETS_PROJECTION;
+      }
+    else if (!strcmp (state, "texture0"))
+      {
+        return irr::video::ETS_TEXTURE_0;
+      }
+    else if (!strcmp (state, "texture1"))
+      {
+        return irr::video::ETS_TEXTURE_1;
+      }
+    else if (!strcmp (state, "texture2"))
+      {
+        return irr::video::ETS_TEXTURE_2;
+      }
+    else if (!strcmp (state, "texture3"))
+      {
+        return irr::video::ETS_TEXTURE_3;
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Wrong transformation state: ~S",
+                   scm_list_1 (transformation_state), scm_list_1 (transformation_state));
+      }
+  }
+
 }