From: Javier Sancho Date: Wed, 4 Mar 2020 18:10:28 +0000 (+0100) Subject: get-gui-environment X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=commitdiff_plain;h=84e93e7eac45dde889fc436a247838da3c87edf6 get-gui-environment --- diff --git a/Makefile.am b/Makefile.am index 62c4bb7..88b5268 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,6 +4,7 @@ libguile_irrlicht_la_SOURCES = \ src/dimension2d.cpp \ src/EDriverTypes.cpp \ src/GuileIrrlicht.cpp \ + src/IGUIEnvironment.cpp \ src/IrrlichtDevice.cpp \ src/ISceneManager.cpp \ src/IVideoDriver.cpp diff --git a/irrlicht/device.scm b/irrlicht/device.scm index a548ee5..f5f8b61 100644 --- a/irrlicht/device.scm +++ b/irrlicht/device.scm @@ -20,6 +20,7 @@ (define-module (irrlicht device) #:export (create-device + get-gui-environment get-scene-manager get-video-driver set-window-caption!)) diff --git a/src/GuileIrrlicht.cpp b/src/GuileIrrlicht.cpp index 33ddda3..5f8691c 100644 --- a/src/GuileIrrlicht.cpp +++ b/src/GuileIrrlicht.cpp @@ -20,6 +20,7 @@ */ #include +#include "IGUIEnvironment.h" #include "IrrlichtDevice.h" #include "ISceneManager.h" #include "IVideoDriver.h" @@ -30,6 +31,7 @@ extern "C" { init_guile_irrlicht (void) { init_device (); + init_gui_environment (); init_scene_manager (); init_video_driver (); } diff --git a/src/IGUIEnvironment.cpp b/src/IGUIEnvironment.cpp new file mode 100644 index 0000000..0f66f72 --- /dev/null +++ b/src/IGUIEnvironment.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 "IGUIEnvironment.h" + +extern "C" { + + void + init_gui_environment (void) + { + init_gui_environment_type (); + } + + static SCM gui_environment_type; + + void + init_gui_environment_type (void) + { + SCM name, slots; + scm_t_struct_finalize finalizer; + + name = scm_from_utf8_symbol ("gui_environment"); + slots = scm_list_1 (scm_from_utf8_symbol ("data")); + finalizer = NULL; + + gui_environment_type = + scm_make_foreign_object_type (name, slots, finalizer); + } + + SCM + wrap_gui_environment (irr::gui::IGUIEnvironment* gui_environment) + { + return scm_make_foreign_object_1 (gui_environment_type, gui_environment); + } + + irr::gui::IGUIEnvironment* + unwrap_gui_environment (SCM gui_environment_obj) + { + scm_assert_foreign_object_type (gui_environment_type, gui_environment_obj); + return (irr::gui::IGUIEnvironment*)scm_foreign_object_ref (gui_environment_obj, 0); + } + +} diff --git a/src/IGUIEnvironment.h b/src/IGUIEnvironment.h new file mode 100644 index 0000000..65fc694 --- /dev/null +++ b/src/IGUIEnvironment.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_GUI_ENVIRONMENT_INCLUDED__ +#define __GUILE_I_GUI_ENVIRONMENT_INCLUDED__ + +#include +#include + +extern "C" { + + void + init_gui_environment (void); + + void + init_gui_environment_type (void); + + SCM + wrap_gui_environment (irr::gui::IGUIEnvironment* gui_environment); + + irr::gui::IGUIEnvironment* + unwrap_gui_environment (SCM gui_environment_obj); + +} + +#endif diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp index 125163f..aa492e1 100644 --- a/src/IrrlichtDevice.cpp +++ b/src/IrrlichtDevice.cpp @@ -25,6 +25,7 @@ #include "dimension2d.h" #include "EDriverTypes.h" +#include "IGUIEnvironment.h" #include "IrrlichtDevice.h" #include "ISceneManager.h" #include "IVideoDriver.h" @@ -36,6 +37,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-gui-environment", 1, 0, 0, (scm_t_subr)irr_getGUIEnvironment); 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); @@ -89,6 +91,14 @@ extern "C" { return wrap_device (device); } + SCM + irr_getGUIEnvironment (SCM device_obj) + { + irr::IrrlichtDevice* device = unwrap_device (device_obj); + irr::gui::IGUIEnvironment* gui_environment = device->getGUIEnvironment(); + return wrap_gui_environment (gui_environment); + } + SCM irr_getSceneManager (SCM device_obj) { diff --git a/src/IrrlichtDevice.h b/src/IrrlichtDevice.h index 3702c6f..5d33bfd 100644 --- a/src/IrrlichtDevice.h +++ b/src/IrrlichtDevice.h @@ -48,6 +48,9 @@ extern "C" { SCM vsync, SCM receiver); + SCM + irr_getGUIEnvironment (SCM device_obj); + SCM irr_getSceneManager (SCM device_obj);