From f842432ad7cfd7f530188e2a4848aea3da03719e Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Mon, 4 May 2020 10:16:10 +0200 Subject: [PATCH] get-video-driver --- Makefile.am | 3 ++- irrlicht.scm | 1 + irrlicht/irr.scm | 18 +++++++++++------- irrlicht/video.scm | 30 ++++++++++++++++++++++++++++++ src/device.cpp | 10 ++++++++++ src/device.h | 5 ++++- src/video-driver.cpp | 18 ------------------ src/video-driver.h | 3 --- 8 files changed, 58 insertions(+), 30 deletions(-) create mode 100644 irrlicht/video.scm diff --git a/Makefile.am b/Makefile.am index fa12476..41f298d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -105,4 +105,5 @@ SOURCES = \ irrlicht.scm \ irrlicht/base.scm \ irrlicht/foreign.scm \ - irrlicht/irr.scm + irrlicht/irr.scm \ + irrlicht/video.scm diff --git a/irrlicht.scm b/irrlicht.scm index b08f2f7..221171c 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -21,4 +21,5 @@ (define-module (irrlicht) #:use-module (irrlicht irr) #:re-export (create-device + get-video-driver set-window-caption!)) diff --git a/irrlicht/irr.scm b/irrlicht/irr.scm index 8eeae76..569a743 100644 --- a/irrlicht/irr.scm +++ b/irrlicht/irr.scm @@ -22,19 +22,20 @@ #:use-module (oop goops) #:use-module (irrlicht base) #:use-module (irrlicht foreign) - #:export ( - - create-device - set-window-caption!)) + #:use-module (irrlicht video)) ;; IReferenceCounted (define-class ()) +(export ) + ;; IEventReceiver (define-class ()) +(export ) + ;; IrrlichtDevice (define-class ()) @@ -63,7 +64,10 @@ vsync (irr-pointer receiver)))) +(define-method (get-video-driver (device )) + (make #:irr-pointer (irr_IrrlichtDevice_getVideoDriver (irr-pointer device)))) + (define-method (set-window-caption! (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 index 0000000..d3b6f8a --- /dev/null +++ b/irrlicht/video.scm @@ -0,0 +1,30 @@ +;;; guile-irrlicht --- FFI bindings for Irrlicht Engine +;;; Copyright (C) 2020 Javier Sancho +;;; +;;; 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 +;;; . + + +(define-module (irrlicht video) + #:use-module (oop goops) + #:use-module (irrlicht base) + #:use-module (irrlicht foreign)) + + +;; IVideoDriver +(define-class ()) + +(export ) diff --git a/src/device.cpp b/src/device.cpp index 195ff5d..b9ce376 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -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) diff --git a/src/device.h b/src/device.h index 8bfb217..3a082be 100644 --- a/src/device.h +++ b/src/device.h @@ -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 diff --git a/src/video-driver.cpp b/src/video-driver.cpp index bd01f6e..61683f2 100644 --- a/src/video-driver.cpp +++ b/src/video-driver.cpp @@ -23,7 +23,6 @@ #include #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) { diff --git a/src/video-driver.h b/src/video-driver.h index 4512b96..0dc32c7 100644 --- a/src/video-driver.h +++ b/src/video-driver.h @@ -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); -- 2.39.2