X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=src%2Fdevice.cpp;h=b9ce376dbe93419e42bad291038f785e47914d8e;hb=f842432ad7cfd7f530188e2a4848aea3da03719e;hp=939685e025650efbdad3909c4823fea93144315a;hpb=df1ada6981c0c98038ba5fe2f09993934405dff2;p=guile-irrlicht.git diff --git a/src/device.cpp b/src/device.cpp index 939685e..b9ce376 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -31,19 +31,24 @@ #include "wchar.h" #include "wrapped.h" +using namespace irr; + extern "C" { void init_device (void) { init_device_type (); - DEFINE_GSUBR ("create-device", 0, 0, 1, irr_createDevice); + DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice); + DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0, + irr_IrrlichtDevice_getVideoDriver); + 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 ("set-window-caption!", 2, 0, 0, irr_setWindowCaption); DEFINE_GSUBR ("yield", 1, 0, 0, irr_yield); } @@ -52,36 +57,40 @@ 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) + { + 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_getVideoDriver (SCM device) + { + video::IVideoDriver* driver = + ((IrrlichtDevice*)scm_to_pointer (device))->getVideoDriver (); + return scm_from_pointer ((void*)driver, NULL); + } + + SCM + irr_IrrlichtDevice_setWindowCaption (SCM device, + SCM text) { - 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_BOOL_F; - SCM stencilbuffer = SCM_BOOL_F; - SCM vsync = SCM_BOOL_F; - SCM receiver = SCM_BOOL_F; - - 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*)scm_to_pointer (device))-> + setWindowCaption (scm_to_wide_char_string (text)); + return SCM_UNSPECIFIED; } SCM @@ -123,15 +132,6 @@ extern "C" { return SCM_UNSPECIFIED; } - SCM - irr_setWindowCaption (SCM wrapped_device, - SCM text) - { - irr::IrrlichtDevice* device = unwrap_device (wrapped_device); - device->setWindowCaption (scm_to_wide_char_string (text)); - return SCM_UNSPECIFIED; - } - SCM irr_yield (SCM wrapped_device) {