From: Javier Sancho Date: Wed, 4 Mar 2020 11:06:01 +0000 (+0100) Subject: set-window-caption! X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=d27297a52c2399bd71661513d93da43a2a3e9ad1;p=guile-irrlicht.git set-window-caption! --- diff --git a/Makefile.am b/Makefile.am index f9c9ed9..a82439d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ libguile_irrlicht_la_SOURCES = \ src/dimension2d.cpp \ src/EDriverTypes.cpp \ src/GuileIrrlicht.cpp \ - src/Irrlicht.cpp + src/IrrlichtDevice.cpp libguile_irrlicht_la_CPPFLAGS = @GUILE_CFLAGS@ libguile_irrlicht_la_LDFLAGS = \ -version-info 0:1 \ diff --git a/irrlicht/device.scm b/irrlicht/device.scm index b697c7f..f359c49 100644 --- a/irrlicht/device.scm +++ b/irrlicht/device.scm @@ -19,7 +19,8 @@ (define-module (irrlicht device) - #:export (create-device)) + #:export (create-device + set-window-caption!)) (load-extension "libguile-irrlicht" "init_guile_irrlicht") diff --git a/src/GuileIrrlicht.cpp b/src/GuileIrrlicht.cpp index d1473c4..6d2c5d7 100644 --- a/src/GuileIrrlicht.cpp +++ b/src/GuileIrrlicht.cpp @@ -20,14 +20,14 @@ */ #include -#include "Irrlicht.h" +#include "IrrlichtDevice.h" extern "C" { void init_guile_irrlicht (void) { - init_irrlicht (); + init_irrlicht_device (); } } diff --git a/src/Irrlicht.cpp b/src/Irrlicht.cpp deleted file mode 100644 index fc42579..0000000 --- a/src/Irrlicht.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* 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 "EDriverTypes.h" -#include "Irrlicht.h" -#include "dimension2d.h" - -extern "C" { - - static SCM irrlicht_device; - - void - init_irrlicht (void) - { - init_irrlicht_device (); - scm_c_define_gsubr ("create-device", 7, 0, 0, (scm_t_subr)irr_createDevice); - } - - void - init_irrlicht_device (void) - { - SCM name, slots; - scm_t_struct_finalize finalizer; - - name = scm_from_utf8_symbol ("device"); - slots = scm_list_1 (scm_from_utf8_symbol ("data")); - finalizer = NULL; - - irrlicht_device = - scm_make_foreign_object_type (name, slots, finalizer); - } - - SCM - irr_createDevice (SCM deviceType, - SCM windowSize, - SCM bits, - SCM fullscreen, - SCM stencilbuffer, - SCM vsync, - SCM receiver) - { - irr::IrrlichtDevice* device = - irr::createDevice (scm_to_driver_type (deviceType), - scm_to_dimension2d_u32 (windowSize), - scm_to_uint32 (bits), - scm_to_bool (fullscreen), - scm_to_bool (stencilbuffer), - scm_to_bool (vsync)); - return scm_make_foreign_object_1 (irrlicht_device, device); - } - -} diff --git a/src/Irrlicht.h b/src/Irrlicht.h deleted file mode 100644 index e2c9826..0000000 --- a/src/Irrlicht.h +++ /dev/null @@ -1,46 +0,0 @@ -/* 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_IRRLICHT_INCLUDED__ -#define __GUILE_IRRLICHT_INCLUDED__ - -#include - -extern "C" { - - void - init_irrlicht (void); - - void - init_irrlicht_device (void); - - SCM - irr_createDevice (SCM deviceType, - SCM windowSize, - SCM bits, - SCM fullscreen, - SCM stencilbuffer, - SCM vsync, - SCM receiver); - -} - -#endif diff --git a/src/IrrlichtDevice.cpp b/src/IrrlichtDevice.cpp new file mode 100644 index 0000000..b3b33bd --- /dev/null +++ b/src/IrrlichtDevice.cpp @@ -0,0 +1,93 @@ +/* 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 +#include "EDriverTypes.h" +#include "IrrlichtDevice.h" +#include "dimension2d.h" + +extern "C" { + + void + init_irrlicht_device (void) + { + init_irrlicht_device_object (); + scm_c_define_gsubr ("create-device", 7, 0, 0, (scm_t_subr)irr_createDevice); + scm_c_define_gsubr ("set-window-caption!", 2, 0, 0, (scm_t_subr)irr_setWindowCaption); + } + + static SCM irrlicht_device; + + void + init_irrlicht_device_object (void) + { + SCM name, slots; + scm_t_struct_finalize finalizer; + + name = scm_from_utf8_symbol ("device"); + slots = scm_list_1 (scm_from_utf8_symbol ("data")); + finalizer = NULL; + + irrlicht_device = + scm_make_foreign_object_type (name, slots, finalizer); + } + + SCM + irr_createDevice (SCM deviceType, + SCM windowSize, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver) + { + irr::IrrlichtDevice* device = + irr::createDevice (scm_to_driver_type (deviceType), + scm_to_dimension2d_u32 (windowSize), + scm_to_uint32 (bits), + scm_to_bool (fullscreen), + scm_to_bool (stencilbuffer), + scm_to_bool (vsync)); + return scm_make_foreign_object_1 (irrlicht_device, device); + } + + SCM + irr_setWindowCaption (SCM device_obj, + SCM text) + { + irr::IrrlichtDevice* device; + char* ctext; + wchar_t* wtext; + + scm_assert_foreign_object_type (irrlicht_device, device_obj); + device = (irr::IrrlichtDevice*)scm_foreign_object_ref (device_obj, 0); + + ctext = scm_to_utf8_stringn (text, NULL); + wtext = (wchar_t*)malloc ((strlen (ctext) + 1) * sizeof (wchar_t)); + mbstowcs (wtext, ctext, strlen (ctext) + 1); + + device->setWindowCaption (wtext); + return SCM_UNSPECIFIED; + } + +} diff --git a/src/IrrlichtDevice.h b/src/IrrlichtDevice.h new file mode 100644 index 0000000..c364903 --- /dev/null +++ b/src/IrrlichtDevice.h @@ -0,0 +1,50 @@ +/* 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_IRRLICHT_DEVICE_INCLUDED__ +#define __GUILE_IRRLICHT_DEVICE_INCLUDED__ + +#include + +extern "C" { + + void + init_irrlicht_device (void); + + void + init_irrlicht_device_object (void); + + SCM + irr_createDevice (SCM deviceType, + SCM windowSize, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver); + + SCM + irr_setWindowCaption (SCM device, + SCM text); + +} + +#endif