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"
28 #include "event-receiver.h"
42 DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice);
43 DEFINE_GSUBR ("irr_IrrlichtDevice_getGUIEnvironment", 1, 0, 0,
44 irr_IrrlichtDevice_getGUIEnvironment);
45 DEFINE_GSUBR ("irr_IrrlichtDevice_getSceneManager", 1, 0, 0,
46 irr_IrrlichtDevice_getSceneManager);
47 DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0,
48 irr_IrrlichtDevice_getVideoDriver);
49 DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0,
50 irr_IrrlichtDevice_setWindowCaption);
51 DEFINE_GSUBR ("get-timer", 1, 0, 0, irr_getTimer);
52 DEFINE_GSUBR ("is-window-active?", 1, 0, 0, irr_isWindowActive);
53 DEFINE_GSUBR ("run", 1, 0, 0, irr_run);
54 DEFINE_GSUBR ("set-event-receiver!", 2, 0, 0, irr_setEventReceiver);
55 DEFINE_GSUBR ("set-resizable!", 2, 0, 0, irr_setResizable);
56 DEFINE_GSUBR ("yield", 1, 0, 0, irr_yield);
59 DEFINE_WRAPPED_TYPE (irr::IrrlichtDevice*, "device",
60 init_device_type, device_p,
61 wrap_device, unwrap_device);
64 irr_createDevice (SCM device_type,
72 IrrlichtDevice* device =
73 createDevice (scm_to_driver_type (device_type),
74 scm_to_dimension2d_u32 (window_size),
76 scm_to_bool (fullscreen),
77 scm_to_bool (stencilbuffer),
79 (IEventReceiver*)scm_to_pointer (receiver));
80 return scm_from_pointer ((void*)device, NULL);
84 irr_IrrlichtDevice_getGUIEnvironment (SCM device){
85 gui::IGUIEnvironment* gui_env =
86 ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment ();
87 return scm_from_pointer ((void*)gui_env, NULL);
91 irr_IrrlichtDevice_getSceneManager (SCM device)
93 scene::ISceneManager* manager =
94 ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager ();
95 return scm_from_pointer ((void*)manager, NULL);
99 irr_IrrlichtDevice_getVideoDriver (SCM device)
101 video::IVideoDriver* driver =
102 ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver ();
103 return scm_from_pointer ((void*)driver, NULL);
107 irr_IrrlichtDevice_setWindowCaption (SCM device,
110 ((IrrlichtDevice*)scm_to_pointer (device))->
111 setWindowCaption (scm_to_wide_char_string (text));
112 return SCM_UNSPECIFIED;
116 irr_getTimer (SCM wrapped_device)
118 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
119 return wrap_timer (device->getTimer ());
123 irr_isWindowActive (SCM wrapped_device)
125 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
126 return scm_from_bool (device->isWindowActive ());
130 irr_run (SCM wrapped_device)
132 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
133 return scm_from_bool (device->run ());
137 irr_setEventReceiver (SCM wrapped_device,
140 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
141 device->setEventReceiver (unwrap_event_receiver (receiver));
142 return SCM_UNSPECIFIED;
146 irr_setResizable (SCM wrapped_device,
149 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
150 device->setResizable (scm_to_bool (resize));
151 return SCM_UNSPECIFIED;
155 irr_yield (SCM wrapped_device)
157 irr::IrrlichtDevice* device = unwrap_device (wrapped_device);
159 return SCM_UNSPECIFIED;