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>
25 #include "dimension2d.h"
26 #include "driver-types.h"
34 template <typename TEventReceiver>
36 createDevice (SCM device_type,
44 IrrlichtDevice* device =
45 createDevice (scm_to_driver_type (device_type),
46 scm_to_dimension2d_u32 (window_size),
48 scm_to_bool (fullscreen),
49 scm_to_bool (stencilbuffer),
51 (TEventReceiver)scm_to_pointer (receiver));
52 return scm_from_pointer ((void*)device, NULL);
57 IrrlichtDevice_getCursorControl (SCM device)
59 gui::ICursorControl* cursor_control =
60 ((IrrlichtDevice*)scm_to_pointer (device))->getCursorControl ();
61 return scm_from_pointer ((void*)cursor_control, NULL);
66 IrrlichtDevice_getFileSystem (SCM device)
68 io::IFileSystem* file_system =
69 ((IrrlichtDevice*)scm_to_pointer (device))->getFileSystem ();
70 return scm_from_pointer ((void*)file_system, NULL);
75 IrrlichtDevice_getGUIEnvironment (SCM device)
77 gui::IGUIEnvironment* gui_env =
78 ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment ();
79 return scm_from_pointer ((void*)gui_env, NULL);
84 IrrlichtDevice_getSceneManager (SCM device)
86 scene::ISceneManager* manager =
87 ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager ();
88 return scm_from_pointer ((void*)manager, NULL);
93 IrrlichtDevice_getTimer (SCM device)
96 ((IrrlichtDevice*)scm_to_pointer (device))->getTimer ();
97 return scm_from_pointer ((void*)timer, NULL);
102 IrrlichtDevice_getVideoDriver (SCM device)
104 video::IVideoDriver* driver =
105 ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver ();
106 return scm_from_pointer ((void*)driver, NULL);
111 IrrlichtDevice_isWindowActive (SCM device)
114 (((IrrlichtDevice*)scm_to_pointer (device))->isWindowActive ());
119 IrrlichtDevice_run (SCM device)
122 (((IrrlichtDevice*)scm_to_pointer (device))->run ());
126 template <typename TEventReceiver>
128 IrrlichtDevice_setEventReceiver (SCM device,
131 ((IrrlichtDevice*)scm_to_pointer (device))->
132 setEventReceiver ((TEventReceiver)scm_to_pointer (receiver));
133 return SCM_UNSPECIFIED;
138 IrrlichtDevice_setResizable (SCM device,
141 ((IrrlichtDevice*)scm_to_pointer (device))->
142 setResizable (scm_to_bool (resize));
143 return SCM_UNSPECIFIED;
148 IrrlichtDevice_setWindowCaption (SCM device,
151 ((IrrlichtDevice*)scm_to_pointer (device))->
152 setWindowCaption (scm_to_wide_char_string (text));
153 return SCM_UNSPECIFIED;
158 IrrlichtDevice_yield (SCM device)
160 ((IrrlichtDevice*)scm_to_pointer (device))->yield ();
161 return SCM_UNSPECIFIED;
170 DEFINE_GSUBR ("createDevice_IEventReceiver", 7, 0, 0, createDevice<IEventReceiver*>);
171 DEFINE_GSUBR ("IrrlichtDevice_getCursorControl", 1, 0, 0, IrrlichtDevice_getCursorControl);
172 DEFINE_GSUBR ("IrrlichtDevice_getFileSystem", 1, 0, 0, IrrlichtDevice_getFileSystem);
173 DEFINE_GSUBR ("IrrlichtDevice_getGUIEnvironment", 1, 0, 0, IrrlichtDevice_getGUIEnvironment);
174 DEFINE_GSUBR ("IrrlichtDevice_getSceneManager", 1, 0, 0, IrrlichtDevice_getSceneManager);
175 DEFINE_GSUBR ("IrrlichtDevice_getTimer", 1, 0, 0, IrrlichtDevice_getTimer);
176 DEFINE_GSUBR ("IrrlichtDevice_getVideoDriver", 1, 0, 0, IrrlichtDevice_getVideoDriver);
177 DEFINE_GSUBR ("IrrlichtDevice_isWindowActive", 1, 0, 0, IrrlichtDevice_isWindowActive);
178 DEFINE_GSUBR ("IrrlichtDevice_run", 1, 0, 0, IrrlichtDevice_run);
179 DEFINE_GSUBR ("IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0,
180 IrrlichtDevice_setEventReceiver<IEventReceiver*>);
181 DEFINE_GSUBR ("IrrlichtDevice_setResizable", 2, 0, 0, IrrlichtDevice_setResizable);
182 DEFINE_GSUBR ("IrrlichtDevice_setWindowCaption", 2, 0, 0, IrrlichtDevice_setWindowCaption);
183 DEFINE_GSUBR ("IrrlichtDevice_yield", 1, 0, 0, IrrlichtDevice_yield);