]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
begin-scene
authorJavier Sancho <jsf@jsancho.org>
Tue, 17 Mar 2020 11:10:35 +0000 (12:10 +0100)
committerJavier Sancho <jsf@jsancho.org>
Tue, 17 Mar 2020 11:10:35 +0000 (12:10 +0100)
Makefile.am
irrlicht/video.scm
src/color.cpp [new file with mode: 0644]
src/color.h [new file with mode: 0644]
src/video-driver.cpp
src/video-driver.h

index a1b60556885802cb1bb6cb2955259e8f1aa51596..e1d88a167b84406ab25c27132e1ee8858d06faa3 100644 (file)
@@ -27,6 +27,7 @@ libguile_irrlicht_la_SOURCES = \
   src/animated-mesh-md2.cpp \
   src/animated-mesh-scene-node.cpp \
   src/camera-scene-node.cpp \
+  src/color.cpp \
   src/device.cpp \
   src/dimension2d.cpp \
   src/driver-types.cpp \
index 77e3d21415f7b3ce68815c7a903ff3da0f19657f..999959550008bb9b35be22b4173b112f408a85f6 100644 (file)
 
 
 (define-module (irrlicht video)
-  #:export (get-texture))
+  #:export (begin-scene
+            get-texture))
 
 (load-extension "libguile-irrlicht" "init_guile_irrlicht")
+
+(define irr-begin-scene begin-scene)
+(define* (begin-scene video-driver
+                      #:key
+                      (back-buffer #t)
+                      (z-buffer #t)
+                      (color '(255 0 0 0))
+                      (video-data #f)
+                      (source-rect #f))
+  (irr-begin-scene video-driver
+                   back-buffer
+                   z-buffer
+                   color
+                   video-data
+                   source-rect))
diff --git a/src/color.cpp b/src/color.cpp
new file mode 100644 (file)
index 0000000..a6879c3
--- /dev/null
@@ -0,0 +1,38 @@
+/* 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 "rect.h"
+
+extern "C" {
+
+  irr::video::SColor
+  scm_to_color (SCM color)
+  {
+    return irr::video::SColor
+      (scm_to_uint32 (scm_car (color)),
+       scm_to_uint32 (scm_cadr (color)),
+       scm_to_uint32 (scm_caddr (color)),
+       scm_to_uint32 (scm_cadddr (color)));
+  }
+
+}
diff --git a/src/color.h b/src/color.h
new file mode 100644 (file)
index 0000000..d85513b
--- /dev/null
@@ -0,0 +1,35 @@
+/* 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/>.
+*/
+
+#ifndef __GUILE_IRRLICHT_COLOR_H_INCLUDED__
+#define __GUILE_IRRLICHT_COLOR_H_INCLUDED__
+
+#include <irrlicht/irrlicht.h>
+#include <libguile.h>
+
+extern "C" {
+
+  irr::video::SColor
+  scm_to_color (SCM color);
+
+}
+
+#endif
index 632f0dec46a8170ec7e4a56fcfc8dadefd157139..dc9cce60da4a42012f2e91fd31ff4912e8f2f732 100644 (file)
@@ -22,7 +22,9 @@
 #include <irrlicht/irrlicht.h>
 #include <libguile.h>
 
+#include "color.h"
 #include "device.h"
+#include "rect.h"
 #include "texture.h"
 #include "video-driver.h"
 #include "wrapped.h"
@@ -33,6 +35,7 @@ extern "C" {
   init_video_driver (void)
   {
     init_video_driver_type ();
+    scm_c_define_gsubr ("begin-scene", 6, 0, 0, (scm_t_subr)irr_video_beginScene);
     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);
   }
@@ -41,6 +44,28 @@ extern "C" {
                        init_video_driver_type, video_driver_p,
                        wrap_video_driver, unwrap_video_driver);
 
+  SCM
+  irr_video_beginScene (SCM wrapped_video_driver,
+                        SCM back_buffer,
+                        SCM z_buffer,
+                        SCM color,
+                        SCM video_data,
+                        SCM source_rect)
+  {
+    irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver);
+    irr::core::rect<irr::s32>* sourceRectAddress = 0;
+    if (!scm_is_false (source_rect))
+      {
+        irr::core::rect<irr::s32> sourceRect = scm_to_rect_s32 (source_rect);
+        sourceRectAddress = &sourceRect;
+      }
+    return scm_from_bool (driver->beginScene (scm_to_bool (back_buffer),
+                                              scm_to_bool (z_buffer),
+                                              scm_to_color (color),
+                                              irr::video::SExposedVideoData (),
+                                              sourceRectAddress));
+  }
+
   SCM
   irr_video_getTexture (SCM wrapped_video_driver,
                         SCM filename)
index 5137ca47e9d74e92dfb05e67f173ee364c7ea1d2..65df39ace0802f173714372cc338f0215ee40b65 100644 (file)
@@ -34,6 +34,14 @@ extern "C" {
   DECLARE_WRAPPED_TYPE (irr::video::IVideoDriver*, init_video_driver_type,
                         video_driver_p, wrap_video_driver, unwrap_video_driver);
 
+  SCM
+  irr_video_beginScene (SCM wrapped_video_driver,
+                        SCM back_buffer,
+                        SCM z_buffer,
+                        SCM color,
+                        SCM video_data,
+                        SCM source_rect);
+
   SCM
   irr_video_getTexture (SCM wrapped_video_driver,
                         SCM filename);