From 37aba303eccc24a407f1b5b0af81623e47b89a22 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 5 May 2020 09:14:57 +0200 Subject: [PATCH] Get irrlicht objects --- Makefile.am | 2 ++ irrlicht.scm | 2 ++ irrlicht/gui.scm | 30 ++++++++++++++++++++++++++++++ irrlicht/irr.scm | 15 +++++++++++++-- irrlicht/scene.scm | 30 ++++++++++++++++++++++++++++++ src/device.cpp | 19 +++++++++++++++++++ src/device.h | 6 ++++++ src/gui-environment.cpp | 17 ----------------- src/gui-environment.h | 3 --- src/scene-manager.cpp | 17 ----------------- src/scene-manager.h | 3 --- 11 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 irrlicht/gui.scm create mode 100644 irrlicht/scene.scm diff --git a/Makefile.am b/Makefile.am index 41f298d..463dccb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -105,5 +105,7 @@ SOURCES = \ irrlicht.scm \ irrlicht/base.scm \ irrlicht/foreign.scm \ + irrlicht/gui.scm \ irrlicht/irr.scm \ + irrlicht/scene.scm \ irrlicht/video.scm diff --git a/irrlicht.scm b/irrlicht.scm index 221171c..f43707d 100644 --- a/irrlicht.scm +++ b/irrlicht.scm @@ -21,5 +21,7 @@ (define-module (irrlicht) #:use-module (irrlicht irr) #:re-export (create-device + get-gui-environment + get-scene-manager get-video-driver set-window-caption!)) diff --git a/irrlicht/gui.scm b/irrlicht/gui.scm new file mode 100644 index 0000000..70a2f97 --- /dev/null +++ b/irrlicht/gui.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 gui) + #:use-module (oop goops) + #:use-module (irrlicht base) + #:use-module (irrlicht foreign)) + + +;; IVideoDriver +(define-class ()) + +(export ) diff --git a/irrlicht/irr.scm b/irrlicht/irr.scm index 569a743..f69701c 100644 --- a/irrlicht/irr.scm +++ b/irrlicht/irr.scm @@ -22,6 +22,8 @@ #:use-module (oop goops) #:use-module (irrlicht base) #:use-module (irrlicht foreign) + #:use-module (irrlicht gui) + #:use-module (irrlicht scene) #:use-module (irrlicht video)) @@ -64,10 +66,19 @@ vsync (irr-pointer receiver)))) +(define-method (get-gui-environment (device )) + (make + #:irr-pointer (irr_IrrlichtDevice_getGUIEnvironment (irr-pointer device)))) + +(define-method (get-scene-manager (device )) + (make + #:irr-pointer (irr_IrrlichtDevice_getSceneManager (irr-pointer device)))) + (define-method (get-video-driver (device )) - (make #:irr-pointer (irr_IrrlichtDevice_getVideoDriver (irr-pointer device)))) + (make + #:irr-pointer (irr_IrrlichtDevice_getVideoDriver (irr-pointer device)))) (define-method (set-window-caption! (device ) text) (irr_IrrlichtDevice_setWindowCaption (irr-pointer device) text)) -(export create-device get-video-driver set-window-caption!) +(export create-device get-gui-environment get-scene-manager get-video-driver set-window-caption!) diff --git a/irrlicht/scene.scm b/irrlicht/scene.scm new file mode 100644 index 0000000..44a5233 --- /dev/null +++ b/irrlicht/scene.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 scene) + #: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 b9ce376..1b06a48 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -40,6 +40,10 @@ extern "C" { { init_device_type (); DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice); + DEFINE_GSUBR ("irr_IrrlichtDevice_getGUIEnvironment", 1, 0, 0, + irr_IrrlichtDevice_getGUIEnvironment); + DEFINE_GSUBR ("irr_IrrlichtDevice_getSceneManager", 1, 0, 0, + irr_IrrlichtDevice_getSceneManager); DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0, irr_IrrlichtDevice_getVideoDriver); DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0, @@ -76,6 +80,21 @@ extern "C" { return scm_from_pointer ((void*)device, NULL); } + SCM + irr_IrrlichtDevice_getGUIEnvironment (SCM device){ + gui::IGUIEnvironment* gui_env = + ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment (); + return scm_from_pointer ((void*)gui_env, NULL); + } + + SCM + irr_IrrlichtDevice_getSceneManager (SCM device) + { + scene::ISceneManager* manager = + ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager (); + return scm_from_pointer ((void*)manager, NULL); + } + SCM irr_IrrlichtDevice_getVideoDriver (SCM device) { diff --git a/src/device.h b/src/device.h index 3a082be..d95e458 100644 --- a/src/device.h +++ b/src/device.h @@ -43,6 +43,12 @@ extern "C" { SCM vsync, SCM receiver); + SCM + irr_IrrlichtDevice_getGUIEnvironment (SCM device); + + SCM + irr_IrrlichtDevice_getSceneManager (SCM device); + SCM irr_IrrlichtDevice_getVideoDriver (SCM device); diff --git a/src/gui-environment.cpp b/src/gui-environment.cpp index 87fe38d..df43fc6 100644 --- a/src/gui-environment.cpp +++ b/src/gui-environment.cpp @@ -54,7 +54,6 @@ extern "C" { DEFINE_GSUBR ("add-static-text!", 3, 0, 1, irr_gui_addStaticText); DEFINE_GSUBR ("add-window!", 2, 0, 1, irr_gui_addWindow); DEFINE_GSUBR ("get-built-in-font", 1, 0, 0, irr_gui_getBuiltInFont); - DEFINE_GSUBR ("get-gui-environment", 1, 0, 0, irr_getGUIEnvironment); DEFINE_GSUBR ("get-skin", 1, 0, 0, irr_gui_getSkin); } @@ -62,22 +61,6 @@ extern "C" { init_gui_environment_type, gui_environment_p, wrap_gui_environment, unwrap_gui_environment); - SCM - irr_getGUIEnvironment (SCM wrapped_obj) - { - irr::gui::IGUIEnvironment* gui_environment; - if (device_p (wrapped_obj)) - { - gui_environment = unwrap_device (wrapped_obj)->getGUIEnvironment (); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get GUI environment from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return wrap_gui_environment (gui_environment); - } - SCM irr_gui_addImage (SCM wrapped_gui_environment, SCM image, diff --git a/src/gui-environment.h b/src/gui-environment.h index 5c6da7e..b26f542 100644 --- a/src/gui-environment.h +++ b/src/gui-environment.h @@ -34,9 +34,6 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::gui::IGUIEnvironment*, init_gui_environment_type, gui_environment_p, wrap_gui_environment, unwrap_gui_environment); - SCM - irr_getGUIEnvironment (SCM wrapped_obj); - SCM irr_gui_addImage (SCM wrapped_gui_environment, SCM image, diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index d17d65c..dfa58e5 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -56,7 +56,6 @@ extern "C" { DEFINE_GSUBR ("create-rotation-animator", 2, 0, 0, irr_scene_createRotationAnimator); DEFINE_GSUBR ("get-mesh", 2, 0, 0, irr_scene_getMesh); DEFINE_GSUBR ("get-root-scene-node", 1, 0, 0, irr_scene_getRootSceneNode); - DEFINE_GSUBR ("get-scene-manager", 1, 0, 0, irr_getSceneManager); } DEFINE_WRAPPED_TYPE (irr::scene::ISceneManager*, "scene-manager", @@ -480,20 +479,4 @@ extern "C" { return wrap_scene_node (smgr->getRootSceneNode ()); } - SCM - irr_getSceneManager (SCM wrapped_obj) - { - irr::scene::ISceneManager* scene_manager; - if (device_p (wrapped_obj)) - { - scene_manager = unwrap_device (wrapped_obj)->getSceneManager (); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get scene manager from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return wrap_scene_manager (scene_manager); - } - } diff --git a/src/scene-manager.h b/src/scene-manager.h index ebd81cf..a400e27 100644 --- a/src/scene-manager.h +++ b/src/scene-manager.h @@ -90,9 +90,6 @@ extern "C" { SCM irr_scene_getRootSceneNode (SCM wrapped_scene_manager); - SCM - irr_getSceneManager (SCM wrapped_obj); - } #endif -- 2.39.2