]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
draw-all end-scene
authorJavier Sancho <jsf@jsancho.org>
Thu, 19 Mar 2020 12:15:58 +0000 (13:15 +0100)
committerJavier Sancho <jsf@jsancho.org>
Thu, 19 Mar 2020 12:15:58 +0000 (13:15 +0100)
examples/01.HelloWorld.scm
src/video-driver.cpp
src/video-driver.h

index 8cbe11e1825105c2388ac834270dab0ea5c79ddd..b480c8934ccbac60ffc0361d3b2253e08649a58d 100644 (file)
@@ -63,8 +63,8 @@
 ;; draw everything
 (while (run device)
   (begin-scene driver #:color '(255 100 101 140))
-  (scene-draw-all scene-manager)
-  (gui-draw-all gui-env)
+  (draw-all scene-manager)
+  (draw-all gui-env)
   (end-scene driver))
 
 ;; delete device
index 57231a6d2623bd342aa934df16b4a9ccbefcd7d7..c811c182a351ce3fd275c0092db3da71d185e37e 100644 (file)
@@ -24,7 +24,9 @@
 
 #include "color.h"
 #include "device.h"
+#include "gui-environment.h"
 #include "rect.h"
+#include "scene-manager.h"
 #include "texture.h"
 #include "video-driver.h"
 #include "wrapped.h"
@@ -36,9 +38,12 @@ extern "C" {
   {
     init_video_driver_type ();
     scm_c_define_gsubr ("begin-scene", 1, 0, 1, (scm_t_subr)irr_video_beginScene);
+    scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_guiscene_drawAll);
+    scm_c_define_gsubr ("end-scene", 1, 0, 0, (scm_t_subr)irr_video_endScene);
     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_export ("begin-scene", "get-texture", "get-video-driver", NULL);
+    scm_c_export ("begin-scene", "draw-all", "end-scene", "get-texture",
+                  "get-video-driver", NULL);
   }
 
   DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver",
@@ -80,6 +85,32 @@ extern "C" {
                                               sourceRectAddress));
   }
 
+  SCM
+  irr_guiscene_drawAll (SCM wrapped_obj)
+  {
+    if (gui_environment_p (wrapped_obj))
+      {
+        unwrap_gui_environment (wrapped_obj)->drawAll ();
+      }
+    else if (scene_manager_p (wrapped_obj))
+      {
+        unwrap_scene_manager (wrapped_obj)->drawAll ();
+      }
+    else
+      {
+        scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S",
+                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
+      }
+    return SCM_UNSPECIFIED;
+  }
+
+  SCM
+  irr_video_endScene (SCM wrapped_video_driver)
+  {
+    irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+    return scm_from_bool (driver->endScene ());
+  }
+
   SCM
   irr_video_getTexture (SCM wrapped_video_driver,
                         SCM filename)
index 64bf068b65dafb2ea7e46309a30af06fe8137e19..0957836e62b94d6618564329be057592d3b545fd 100644 (file)
@@ -38,6 +38,12 @@ extern "C" {
   irr_video_beginScene (SCM wrapped_video_driver,
                         SCM rest);
 
+  SCM
+  irr_guiscene_drawAll (SCM wrapped_obj);
+
+  SCM
+  irr_video_endScene (SCM wrapped_video_driver);
+
   SCM
   irr_video_getTexture (SCM wrapped_video_driver,
                         SCM filename);