From 2dd8c4827c6c6afaba10fd04f50ec1587a750be5 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Wed, 4 Mar 2020 18:52:07 +0100 Subject: [PATCH] get-scene-manager --- Makefile.am | 1 + irrlicht/device.scm | 1 + src/GuileIrrlicht.cpp | 2 ++ src/ISceneManager.cpp | 63 ++++++++++++++++++++++++++++++++++++++++++ src/ISceneManager.h | 44 +++++++++++++++++++++++++++++ src/IrrlichtDevice.cpp | 10 +++++++ src/IrrlichtDevice.h | 3 ++ 7 files changed, 124 insertions(+) create mode 100644 src/ISceneManager.cpp create mode 100644 src/ISceneManager.h diff --git a/Makefile.am b/Makefile.am index 8e87700..62c4bb7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,6 +5,7 @@ libguile_irrlicht_la_SOURCES = \ src/EDriverTypes.cpp \ src/GuileIrrlicht.cpp \ src/IrrlichtDevice.cpp \ + src/ISceneManager.cpp \ src/IVideoDriver.cpp libguile_irrlicht_la_CPPFLAGS = @GUILE_CFLAGS@ libguile_irrlicht_la_LDFLAGS = \ diff --git a/irrlicht/device.scm b/irrlicht/device.scm index 8a7b30d..a548ee5 100644 --- a/irrlicht/device.scm +++ b/irrlicht/device.scm @@ -20,6 +20,7 @@ (define-module (irrlicht device) #:export (create-device + get-scene-manager get-video-driver set-window-caption!)) diff --git a/src/GuileIrrlicht.cpp b/src/GuileIrrlicht.cpp index 3dd6c3a..33ddda3 100644 --- a/src/GuileIrrlicht.cpp +++ b/src/GuileIrrlicht.cpp @@ -21,6 +21,7 @@ #include #include "IrrlichtDevice.h" +#include "ISceneManager.h" #include "IVideoDriver.h" extern "C" { @@ -29,6 +30,7 @@ extern "C" { init_guile_irrlicht (void) { init_device (); + init_scene_manager (); init_video_driver (); } diff --git a/src/ISceneManager.cpp b/src/ISceneManager.cpp new file mode 100644 index 0000000..164af46 --- /dev/null +++ b/src/ISceneManager.cpp @@ -0,0 +1,63 @@ +/* guile-irrlicht --- GNU Guile 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 + . +*/ + +#include +#include +#include "ISceneManager.h" + +extern "C" { + + void + init_scene_manager (void) + { + init_scene_manager_type (); + } + + static SCM scene_manager_type; + + void + init_scene_manager_type (void) + { + SCM name, slots; + scm_t_struct_finalize finalizer; + + name = scm_from_utf8_symbol ("scene-manager"); + slots = scm_list_1 (scm_from_utf8_symbol ("data")); + finalizer = NULL; + + scene_manager_type = + scm_make_foreign_object_type (name, slots, finalizer); + } + + SCM + wrap_scene_manager (irr::scene::ISceneManager* scene_manager) + { + return scm_make_foreign_object_1 (scene_manager_type, scene_manager); + } + + irr::scene::ISceneManager* + unwrap_scene_manager (SCM scene_manager_obj) + { + scm_assert_foreign_object_type (scene_manager_type, scene_manager_obj); + return (irr::scene::ISceneManager*)scm_foreign_object_ref (scene_manager_obj, 0); + } + +} diff --git a/src/ISceneManager.h b/src/ISceneManager.h new file mode 100644 index 0000000..561a865 --- /dev/null +++ b/src/ISceneManager.h @@ -0,0 +1,44 @@ +/* guile-irrlicht --- GNU Guile 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 + . +*/ + +#ifndef __GUILE_I_SCENE_MANAGER_INCLUDED__ +#define __GUILE_I_SCENE_MANAGER_INCLUDED__ + +#include +#include + +extern "C" { + + void + init_scene_manager (void); + + void + init_scene_manager_type (void); + + SCM + wrap_scene_manager (irr::scene::ISceneManager* scene_manager); + + irr::scene::ISceneManager* + unwrap_scene_manager (SCM scene_manager_obj); + +} + +#endif diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp index 66c8c54..125163f 100644 --- a/src/IrrlichtDevice.cpp +++ b/src/IrrlichtDevice.cpp @@ -26,6 +26,7 @@ #include "dimension2d.h" #include "EDriverTypes.h" #include "IrrlichtDevice.h" +#include "ISceneManager.h" #include "IVideoDriver.h" extern "C" { @@ -35,6 +36,7 @@ extern "C" { { init_device_type (); scm_c_define_gsubr ("create-device", 7, 0, 0, (scm_t_subr)irr_createDevice); + scm_c_define_gsubr ("get-scene-manager", 1, 0, 0, (scm_t_subr)irr_getSceneManager); scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver); scm_c_define_gsubr ("set-window-caption!", 2, 0, 0, (scm_t_subr)irr_setWindowCaption); } @@ -87,6 +89,14 @@ extern "C" { return wrap_device (device); } + SCM + irr_getSceneManager (SCM device_obj) + { + irr::IrrlichtDevice* device = unwrap_device (device_obj); + irr::scene::ISceneManager* scene_manager = device->getSceneManager(); + return wrap_scene_manager (scene_manager); + } + SCM irr_getVideoDriver (SCM device_obj) { diff --git a/src/IrrlichtDevice.h b/src/IrrlichtDevice.h index 6f8afea..3702c6f 100644 --- a/src/IrrlichtDevice.h +++ b/src/IrrlichtDevice.h @@ -48,6 +48,9 @@ extern "C" { SCM vsync, SCM receiver); + SCM + irr_getSceneManager (SCM device_obj); + SCM irr_getVideoDriver (SCM device_obj); -- 2.39.2