1 /* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine
3 Copyright (C) 2020 Javier Sancho <jsf@jsancho.org>
5 This file is part of guile-irrlicht.
7 guile-irrlicht is free software; you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as
9 published by the Free Software Foundation; either version 3 of the
10 License, or (at your option) any later version.
12 guile-irrlicht is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with guile-irrlicht. If not, see
19 <http://www.gnu.org/licenses/>.
22 #include <irrlicht/irrlicht.h>
26 #include "dimension2d.h"
27 #include "driver-types.h"
37 scm_c_define_gsubr ("create-device", 0, 0, 1, (scm_t_subr)irr_createDevice);
38 scm_c_define_gsubr ("run", 1, 0, 0, (scm_t_subr)irr_run);
39 scm_c_define_gsubr ("set-window-caption!", 2, 0, 0, (scm_t_subr)irr_setWindowCaption);
40 scm_c_export ("create-device", "run", "set-window-caption!", NULL);
43 DEFINE_WRAPPED_TYPE (irr::IrrlichtDevice*, "device",
44 init_device_type, device_p,
45 wrap_device, unwrap_device);
48 irr_createDevice (SCM rest)
50 SCM device_type = scm_from_utf8_symbol ("software");
51 SCM window_size = scm_list_2 (scm_from_uint32 (640),
52 scm_from_uint32 (480));
53 SCM bits = scm_from_uint32 (16);
54 SCM fullscreen = scm_from_bool (0);
55 SCM stencilbuffer = scm_from_bool (0);
56 SCM vsync = scm_from_bool (0);
57 SCM receiver = scm_from_bool (0);
59 scm_c_bind_keyword_arguments ("create-device", rest, (scm_t_keyword_arguments_flags)0,
60 scm_from_utf8_keyword ("device-type"), &device_type,
61 scm_from_utf8_keyword ("window-size"), &window_size,
62 scm_from_utf8_keyword ("bits"), &bits,
63 scm_from_utf8_keyword ("fullscreen"), &fullscreen,
64 scm_from_utf8_keyword ("stencilbuffer"), &stencilbuffer,
65 scm_from_utf8_keyword ("vsync"), &vsync,
66 scm_from_utf8_keyword ("receiver"), &receiver,
69 irr::IrrlichtDevice* device =
70 irr::createDevice (scm_to_driver_type (device_type),
71 scm_to_dimension2d_u32 (window_size),
73 scm_to_bool (fullscreen),
74 scm_to_bool (stencilbuffer),
76 return wrap_device (device);
80 irr_run (SCM wrapped_device)
82 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
83 return scm_from_bool (device->run ());
87 irr_setWindowCaption (SCM wrapped_device,
90 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
91 device->setWindowCaption (scm_to_wide_char_string (text));
92 return SCM_UNSPECIFIED;