From: Javier Sancho Date: Thu, 7 May 2020 11:15:42 +0000 (+0200) Subject: device X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=21c2a906c994af63024cbf38c7849f8976300bbb;p=guile-irrlicht.git device --- diff --git a/src/device.cpp b/src/device.cpp index 1b06a48..4ff21a5 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -21,142 +21,168 @@ #include #include - #include "device.h" #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; + +template +SCM +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), + (TEventReceiver)scm_to_pointer (receiver)); + return scm_from_pointer ((void*)device, NULL); +} + + +SCM +irr_IrrlichtDevice_getCursorControl (SCM device) +{ + gui::ICursorControl* cursor_control = + ((IrrlichtDevice*)scm_to_pointer (device))->getCursorControl (); + return scm_from_pointer ((void*)cursor_control, NULL); +} + + +SCM +irr_IrrlichtDevice_getGUIEnvironment (SCM device) +{ + gui::IGUIEnvironment* gui_env = + ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment (); + return scm_from_pointer ((void*)gui_env, NULL); +} + + +SCM +irr_IrrlichtDevice_getSceneManager (SCM device) +{ + scene::ISceneManager* manager = + ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager (); + return scm_from_pointer ((void*)manager, NULL); +} + + +SCM +irr_IrrlichtDevice_getTimer (SCM device) +{ + ITimer* timer = + ((IrrlichtDevice*)scm_to_pointer (device))->getTimer (); + return scm_from_pointer ((void*)timer, 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_isWindowActive (SCM device) +{ + return scm_from_bool + (((IrrlichtDevice*)scm_to_pointer (device))->isWindowActive ()); +} + + +SCM +irr_IrrlichtDevice_run (SCM device) +{ + return scm_from_bool + (((IrrlichtDevice*)scm_to_pointer (device))->run ()); +} + + +template +SCM +irr_IrrlichtDevice_setEventReceiver (SCM device, + SCM receiver) +{ + ((IrrlichtDevice*)scm_to_pointer (device))-> + setEventReceiver ((TEventReceiver)scm_to_pointer (receiver)); + return SCM_UNSPECIFIED; +} + + +SCM +irr_IrrlichtDevice_setResizable (SCM device, + SCM resize) +{ + ((IrrlichtDevice*)scm_to_pointer (device))-> + setResizable (scm_to_bool (resize)); + return SCM_UNSPECIFIED; +} + + +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_IrrlichtDevice_yield (SCM device) +{ + ((IrrlichtDevice*)scm_to_pointer (device))->yield (); + return SCM_UNSPECIFIED; +} + + extern "C" { void init_device (void) { init_device_type (); - DEFINE_GSUBR ("irr_createDevice", 7, 0, 0, irr_createDevice); + DEFINE_GSUBR ("irr_createDevice_IEventReceiver", 7, 0, 0, + irr_createDevice); + DEFINE_GSUBR ("irr_IrrlichtDevice_getCursorControl", 1, 0, 0, + irr_IrrlichtDevice_getCursorControl); DEFINE_GSUBR ("irr_IrrlichtDevice_getGUIEnvironment", 1, 0, 0, irr_IrrlichtDevice_getGUIEnvironment); DEFINE_GSUBR ("irr_IrrlichtDevice_getSceneManager", 1, 0, 0, irr_IrrlichtDevice_getSceneManager); + DEFINE_GSUBR ("irr_IrrlichtDevice_getTimer", 1, 0, 0, + irr_IrrlichtDevice_getTimer); DEFINE_GSUBR ("irr_IrrlichtDevice_getVideoDriver", 1, 0, 0, irr_IrrlichtDevice_getVideoDriver); + DEFINE_GSUBR ("irr_IrrlichtDevice_isWindowActive", 1, 0, 0, + irr_IrrlichtDevice_isWindowActive); + DEFINE_GSUBR ("irr_IrrlichtDevice_run", 1, 0, 0, + irr_IrrlichtDevice_run); + DEFINE_GSUBR ("irr_IrrlichtDevice_setEventReceiver_IEventReceiver", 2, 0, 0, + irr_IrrlichtDevice_setEventReceiver); + DEFINE_GSUBR ("irr_IrrlichtDevice_setResizable", 2, 0, 0, + irr_IrrlichtDevice_setResizable); 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", - init_device_type, device_p, - wrap_device, unwrap_device); - - SCM - 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_getGUIEnvironment (SCM device){ - gui::IGUIEnvironment* gui_env = - ((IrrlichtDevice*)scm_to_pointer (device))->getGUIEnvironment (); - return scm_from_pointer ((void*)gui_env, NULL); - } - - SCM - irr_IrrlichtDevice_getSceneManager (SCM device) - { - scene::ISceneManager* manager = - ((IrrlichtDevice*)scm_to_pointer (device))->getSceneManager (); - return scm_from_pointer ((void*)manager, 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) - { - ((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 - irr_isWindowActive (SCM wrapped_device) - { - irr::IrrlichtDevice* device = unwrap_device (wrapped_device); - return scm_from_bool (device->isWindowActive ()); - } - - SCM - irr_run (SCM wrapped_device) - { - irr::IrrlichtDevice* device = unwrap_device (wrapped_device); - return scm_from_bool (device->run ()); - } - - SCM - 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->setResizable (scm_to_bool (resize)); - return SCM_UNSPECIFIED; - } - - SCM - irr_yield (SCM wrapped_device) - { - irr::IrrlichtDevice* device = unwrap_device (wrapped_device); - device->yield (); - return SCM_UNSPECIFIED; + DEFINE_GSUBR ("irr_IrrlichtDevice_yield", 1, 0, 0, + irr_IrrlichtDevice_yield); } } diff --git a/src/device.h b/src/device.h index d95e458..3e0e27b 100644 --- a/src/device.h +++ b/src/device.h @@ -24,58 +24,57 @@ #include #include -#include "wrapped.h" -extern "C" { - - void - init_device (void); +template +SCM +irr_createDevice (SCM device_type, + SCM window_size, + SCM bits, + SCM fullscreen, + SCM stencilbuffer, + SCM vsync, + SCM receiver); - DECLARE_WRAPPED_TYPE (irr::IrrlichtDevice*, init_device_type, - device_p, wrap_device, unwrap_device); +SCM +irr_IrrlichtDevice_getCursorControl (SCM device); - SCM - irr_createDevice (SCM device_type, - SCM window_size, - SCM bits, - SCM fullscreen, - SCM stencilbuffer, - SCM vsync, - SCM receiver); +SCM +irr_IrrlichtDevice_getGUIEnvironment (SCM device); - SCM - irr_IrrlichtDevice_getGUIEnvironment (SCM device); +SCM +irr_IrrlichtDevice_getSceneManager (SCM device); - SCM - irr_IrrlichtDevice_getSceneManager (SCM device); +SCM +irr_IrrlichtDevice_getTimer (SCM device); - SCM - irr_IrrlichtDevice_getVideoDriver (SCM device); +SCM +irr_IrrlichtDevice_getVideoDriver (SCM device); - SCM - irr_IrrlichtDevice_setWindowCaption (SCM device, - SCM text); +SCM +irr_IrrlichtDevice_isWindowActive (SCM device); - SCM - irr_getTimer (SCM wrapped_device); +SCM +irr_IrrlichtDevice_run (SCM device); - SCM - irr_isWindowActive (SCM wrapped_device); +template +SCM +irr_IrrlichtDevice_setEventReceiver (SCM device, + SCM receiver); - SCM - irr_run (SCM wrapped_device); +SCM +irr_IrrlichtDevice_setResizable (SCM device, + SCM resize); - SCM - irr_setEventReceiver (SCM wrapped_device, - SCM receiver); +SCM +irr_IrrlichtDevice_setWindowCaption (SCM device, + SCM text); - SCM - irr_setResizable (SCM wrapped_device, - SCM resize); - - SCM - irr_yield (SCM wrapped_device); +SCM +irr_IrrlichtDevice_yield (SCM device); +extern "C" { + void + init_device (void); } #endif