X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fdevice.cpp;h=195ff5dcb13dbe301216f87fd27b67229346bb88;hb=564416a9178fd8cef21364c2d921af6c8166115d;hp=0a4d2c686560e1814719291e6246701aec0fbd44;hpb=a07c344063e6dca568add5f022c7aab495061d11;p=guile-irrlicht.git diff --git a/src/device.cpp b/src/device.cpp index 0a4d2c6..195ff5d 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -26,22 +26,28 @@ #include "dimension2d.h" #include "driver-types.h" #include "event-receiver.h" +#include "gsubr.h" +#include "timer.h" #include "wchar.h" #include "wrapped.h" +using namespace irr; + extern "C" { void init_device (void) { init_device_type (); - scm_c_define_gsubr ("create-device", 0, 0, 1, (scm_t_subr)irr_createDevice); - scm_c_define_gsubr ("is-window-active?", 1, 0, 0, (scm_t_subr)irr_isWindowActive); - scm_c_define_gsubr ("run", 1, 0, 0, (scm_t_subr)irr_run); - scm_c_define_gsubr ("set-window-caption!", 2, 0, 0, (scm_t_subr)irr_setWindowCaption); - scm_c_define_gsubr ("yield", 1, 0, 0, (scm_t_subr)irr_yield); - scm_c_export ("create-device", "is-window-active?", "run", - "set-window-caption!", "yield", NULL); + DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice); + DEFINE_GSUBR ("irr_IrrlichtDevice_setWindowCaption", 2, 0, 0, + irr_IrrlichtDevice_setWindowCaption); + DEFINE_GSUBR ("get-timer", 1, 0, 0, irr_getTimer); + DEFINE_GSUBR ("is-window-active?", 1, 0, 0, irr_isWindowActive); + DEFINE_GSUBR ("run", 1, 0, 0, irr_run); + DEFINE_GSUBR ("set-event-receiver!", 2, 0, 0, irr_setEventReceiver); + DEFINE_GSUBR ("set-resizable!", 2, 0, 0, irr_setResizable); + DEFINE_GSUBR ("yield", 1, 0, 0, irr_yield); } DEFINE_WRAPPED_TYPE (irr::IrrlichtDevice*, "device", @@ -49,36 +55,39 @@ extern "C" { wrap_device, unwrap_device); SCM - irr_createDevice (SCM rest) + irr_createDevice (SCM device_type, + SCM window_size, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver) { - SCM device_type = scm_from_utf8_symbol ("software"); - SCM window_size = scm_list_2 (scm_from_uint32 (640), - scm_from_uint32 (480)); - SCM bits = scm_from_uint32 (16); - SCM fullscreen = scm_from_bool (0); - SCM stencilbuffer = scm_from_bool (0); - SCM vsync = scm_from_bool (0); - SCM receiver = scm_from_bool (0); - - scm_c_bind_keyword_arguments ("create-device", rest, (scm_t_keyword_arguments_flags)0, - scm_from_utf8_keyword ("device-type"), &device_type, - scm_from_utf8_keyword ("window-size"), &window_size, - scm_from_utf8_keyword ("bits"), &bits, - scm_from_utf8_keyword ("fullscreen"), &fullscreen, - scm_from_utf8_keyword ("stencilbuffer"), &stencilbuffer, - scm_from_utf8_keyword ("vsync"), &vsync, - scm_from_utf8_keyword ("receiver"), &receiver, - SCM_UNDEFINED); - - irr::IrrlichtDevice* device = - irr::createDevice (scm_to_driver_type (device_type), - scm_to_dimension2d_u32 (window_size), - scm_to_uint32 (bits), - scm_to_bool (fullscreen), - scm_to_bool (stencilbuffer), - scm_to_bool (vsync), - scm_is_false (receiver) ? 0 : unwrap_event_receiver (receiver)); - return wrap_device (device); + IrrlichtDevice* device = + createDevice (scm_to_driver_type (device_type), + scm_to_dimension2d_u32 (window_size), + scm_to_uint32 (bits), + scm_to_bool (fullscreen), + scm_to_bool (stencilbuffer), + scm_to_bool (vsync), + (IEventReceiver*)scm_to_pointer (receiver)); + return scm_from_pointer ((void*)device, NULL); + } + + SCM + irr_IrrlichtDevice_setWindowCaption (SCM device, + SCM text) + { + ((IrrlichtDevice*)scm_to_pointer (device))-> + setWindowCaption (scm_to_wide_char_string (text)); + return SCM_UNSPECIFIED; + } + + SCM + irr_getTimer (SCM wrapped_device) + { + irr::IrrlichtDevice* device = unwrap_device (wrapped_device); + return wrap_timer (device->getTimer ()); } SCM @@ -96,11 +105,20 @@ extern "C" { } SCM - irr_setWindowCaption (SCM wrapped_device, - SCM text) + irr_setEventReceiver (SCM wrapped_device, + SCM receiver) + { + irr::IrrlichtDevice* device = unwrap_device (wrapped_device); + device->setEventReceiver (unwrap_event_receiver (receiver)); + return SCM_UNSPECIFIED; + } + + SCM + irr_setResizable (SCM wrapped_device, + SCM resize) { irr::IrrlichtDevice* device = unwrap_device (wrapped_device); - device->setWindowCaption (scm_to_wide_char_string (text)); + device->setResizable (scm_to_bool (resize)); return SCM_UNSPECIFIED; }