]> git.jsancho.org Git - guile-irrlicht.git/commitdiff
get-video-driver
authorJavier Sancho <jsf@jsancho.org>
Mon, 4 May 2020 08:16:10 +0000 (10:16 +0200)
committerJavier Sancho <jsf@jsancho.org>
Mon, 4 May 2020 08:16:10 +0000 (10:16 +0200)
Makefile.am
irrlicht.scm
irrlicht/irr.scm
irrlicht/video.scm [new file with mode: 0644]
src/device.cpp
src/device.h
src/video-driver.cpp
src/video-driver.h

index fa12476c1eac43ea6f6e9ddc58c77c029e59bd95..41f298df221338239da01ae4bfffd1a98132bcac 100644 (file)
@@ -105,4 +105,5 @@ SOURCES = \
   irrlicht.scm \
   irrlicht/base.scm \
   irrlicht/foreign.scm \
-  irrlicht/irr.scm
+  irrlicht/irr.scm \
+  irrlicht/video.scm
index b08f2f700b06ccce1658d676d81e2eb3937121fd..221171ccbb7d4b763641c1b20df508d38131aefc 100644 (file)
@@ -21,4 +21,5 @@
 (define-module (irrlicht)
   #:use-module (irrlicht irr)
   #:re-export (create-device
+               get-video-driver
                set-window-caption!))
index 8eeae76ed78645c98b4e9265840fdf3fbe01c916..569a7432bb41d58dd5864e59eeb7cc793d1c2421 100644 (file)
   #:use-module (oop goops)
   #:use-module (irrlicht base)
   #:use-module (irrlicht foreign)
-  #:export (<reference-counted>
-            <irrlicht-device>
-            create-device
-            set-window-caption!))
+  #:use-module (irrlicht video))
 
 
 ;; IReferenceCounted
 (define-class <reference-counted> (<irrlicht-base>))
 
+(export <reference-counted>)
+
 
 ;; IEventReceiver
 (define-class <event-receiver> (<irrlicht-base>))
 
+(export <event-receiver>)
+
 
 ;; IrrlichtDevice
 (define-class <irrlicht-device> (<reference-counted>))
      vsync
      (irr-pointer receiver))))
 
+(define-method (get-video-driver (device <irrlicht-device>))
+  (make <video-driver> #:irr-pointer (irr_IrrlichtDevice_getVideoDriver (irr-pointer device))))
+
 (define-method (set-window-caption! (device <irrlicht-device>) text)
-  (irr_IrrlichtDevice_setWindowCaption
-   (irr-pointer device)
-   text))
+  (irr_IrrlichtDevice_setWindowCaption (irr-pointer device) text))
+
+(export create-device get-video-driver set-window-caption!)
diff --git a/irrlicht/video.scm b/irrlicht/video.scm
new file mode 100644 (file)
index 0000000..d3b6f8a
--- /dev/null
@@ -0,0 +1,30 @@
+;;; guile-irrlicht --- FFI 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/>.
+
+
+(define-module (irrlicht video)
+  #:use-module (oop goops)
+  #:use-module (irrlicht base)
+  #:use-module (irrlicht foreign))
+
+
+;; IVideoDriver
+(define-class <video-driver> (<irrlicht-base>))
+
+(export <video-driver>)
index 195ff5dcb13dbe301216f87fd27b67229346bb88..b9ce376dbe93419e42bad291038f785e47914d8e 100644 (file)
@@ -40,6 +40,8 @@ extern "C" {
   {
     init_device_type ();
     DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice);
+    DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0,
+                  irr_IrrlichtDevice_getVideoDriver);
     DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0,
                   irr_IrrlichtDevice_setWindowCaption);
     DEFINE_GSUBR ("get-timer", 1, 0, 0, irr_getTimer);
@@ -74,6 +76,14 @@ extern "C" {
     return scm_from_pointer ((void*)device, NULL);
   }
 
+  SCM
+  irr_IrrlichtDevice_getVideoDriver (SCM device)
+  {
+    video::IVideoDriver* driver =
+      ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver ();
+    return scm_from_pointer ((void*)driver, NULL);
+  }
+
   SCM
   irr_IrrlichtDevice_setWindowCaption (SCM device,
                                        SCM text)
index 8bfb217805714b7c24345a27e7d3a9c365662a8d..3a082bee417407803af81d3a30f6c343927b52d3 100644 (file)
@@ -44,7 +44,10 @@ extern "C" {
                     SCM receiver);
 
   SCM
-  irr_IrrlichtDevice_setWindowCaption (SCM wrapped_device,
+  irr_IrrlichtDevice_getVideoDriver (SCM device);
+
+  SCM
+  irr_IrrlichtDevice_setWindowCaption (SCM device,
                                        SCM text);
 
   SCM
index bd01f6ea7fce5ebee3a45d4ade6b4f94eaa1bfdd..61683f2436459c24734641160e9588b227ab27e1 100644 (file)
@@ -23,7 +23,6 @@
 #include <libguile.h>
 
 #include "color.h"
-#include "device.h"
 #include "gsubr.h"
 #include "gui-environment.h"
 #include "material.h"
@@ -47,7 +46,6 @@ extern "C" {
     DEFINE_GSUBR ("end-scene", 1, 0, 0, irr_video_endScene);
     DEFINE_GSUBR ("get-fps", 1, 0, 0, irr_video_getFPS);
     DEFINE_GSUBR ("get-texture", 2, 0, 0, irr_video_getTexture);
-    DEFINE_GSUBR ("get-video-driver", 1, 0, 0, irr_getVideoDriver);
     DEFINE_GSUBR ("set-transform!", 3, 0, 0, irr_video_setTransform);
   }
 
@@ -182,22 +180,6 @@ extern "C" {
     return SCM_UNSPECIFIED;
   }
 
-  SCM
-  irr_getVideoDriver (SCM wrapped_obj)
-  {
-    irr::video::IVideoDriver* driver;
-    if (device_p (wrapped_obj))
-      {
-        driver = unwrap_device (wrapped_obj)->getVideoDriver ();
-      }
-    else
-      {
-        scm_error (scm_arg_type_key, NULL, "Cannot get video driver from object: ~S",
-                   scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj));
-      }
-    return wrap_video_driver (driver);
-  }
-
   irr::video::E_TRANSFORMATION_STATE
   scm_to_transformation_state (SCM transformation_state)
   {
index 4512b9689d46182bcff08272258349f6fb40c437..0dc32c7c6d1d0c80d067aeec805c089287fbe4d6 100644 (file)
@@ -63,9 +63,6 @@ extern "C" {
                           SCM state,
                           SCM mat);
 
-  SCM
-  irr_getVideoDriver (SCM wrapped_obj);
-
   irr::video::E_TRANSFORMATION_STATE
   scm_to_transformation_state (SCM transformation_state);