From: Javier Sancho Date: Sat, 9 May 2020 11:58:48 +0000 (+0200) Subject: guile-irrlicht X-Git-Url: https://git.jsancho.org/?p=guile-irrlicht.git;a=commitdiff_plain;h=af95bcdb523274a0a768e173807958ffe16e020d guile-irrlicht --- diff --git a/src/gui-environment.cpp b/src/gui-environment.cpp index 00ca228..5af4968 100644 --- a/src/gui-environment.cpp +++ b/src/gui-environment.cpp @@ -173,6 +173,14 @@ gui_IGUIEnvironment_addWindow (SCM gui_environment, } +SCM +gui_IGUIEnvironment_drawAll (SCM gui_environment) +{ + ((gui::IGUIEnvironment*)scm_to_pointer (gui_environment))->drawAll (); + return SCM_UNSPECIFIED; +} + + SCM gui_IGUIEnvironment_getBuiltInFont (SCM gui_environment) { @@ -221,6 +229,7 @@ extern "C" { gui_IGUIEnvironment_addStaticText); DEFINE_GSUBR ("gui_IGUIEnvironment_addWindow_IGUIElement", 6, 0, 0, gui_IGUIEnvironment_addWindow); + DEFINE_GSUBR ("gui_IGUIEnvironment_drawAll", 1, 0, 0, gui_IGUIEnvironment_drawAll); DEFINE_GSUBR ("gui_IGUIEnvironment_getBuiltInFont", 1, 0, 0, gui_IGUIEnvironment_getBuiltInFont); DEFINE_GSUBR ("gui_IGUIEnvironment_getFont", 2, 0, 0, gui_IGUIEnvironment_getFont); DEFINE_GSUBR ("gui_IGUIEnvironment_getSkin", 1, 0, 0, gui_IGUIEnvironment_getSkin); diff --git a/src/gui-environment.h b/src/gui-environment.h index 663c419..064cb5d 100644 --- a/src/gui-environment.h +++ b/src/gui-environment.h @@ -89,6 +89,9 @@ gui_IGUIEnvironment_addWindow (SCM gui_environment, SCM parent, SCM id); +SCM +gui_IGUIEnvironment_drawAll (SCM gui_environment); + SCM gui_IGUIEnvironment_getBuiltInFont (SCM gui_environment); diff --git a/src/guile-irrlicht.cpp b/src/guile-irrlicht.cpp index 7ea6f7a..e0c4282 100644 --- a/src/guile-irrlicht.cpp +++ b/src/guile-irrlicht.cpp @@ -20,45 +20,33 @@ */ #include - #include "animated-mesh.h" #include "animated-mesh-scene-node.h" #include "box3d.h" -#include "camera-scene-node.h" #include "cursor-control.h" #include "device.h" #include "event-receiver.h" -#include "file-list.h" -#include "gsubr.h" #include "gui.h" -#include "gui-element.h" -#include "gui-environment.h" #include "guile-irrlicht.h" #include "io.h" #include "keymap.h" #include "material.h" -#include "mesh.h" -#include "mesh-scene-node.h" #include "reference-counted.h" #include "scene-manager.h" #include "scene-node.h" -#include "scene-node-animator.h" -#include "texture.h" #include "timer.h" #include "vertex3d.h" #include "video-driver.h" -#include "wchar.h" + extern "C" { void init_guile_irrlicht (void) { - // Init modules init_animated_mesh (); init_animated_mesh_scene_node (); init_box3d (); - init_camera_scene_node (); init_cursor_control (); init_device (); init_event_receiver (); @@ -66,177 +54,12 @@ extern "C" { init_io (); init_keymap (); init_material (); - init_mesh (); - init_mesh_scene_node (); init_reference_counted (); init_scene_manager (); init_scene_node (); - init_scene_node_animator (); - init_texture (); init_timer (); init_vertex3d (); init_video_driver (); - - // Shared procedures (used by two or more objects) - DEFINE_GSUBR ("draw-all", 1, 0, 0, irr_drawAll); - DEFINE_GSUBR ("get-id", 1, 1, 0, irr_getID); - DEFINE_GSUBR ("get-name", 1, 0, 0, irr_getName); - DEFINE_GSUBR ("get-position", 1, 1, 0, irr_getPosition); - DEFINE_GSUBR ("set-material!", 2, 0, 0, irr_setMaterial); - DEFINE_GSUBR ("set-material-flag!", 3, 0, 0, irr_setMaterialFlag); - DEFINE_GSUBR ("set-position!", 2, 0, 0, irr_setPosition); - DEFINE_GSUBR ("set-visible!", 2, 0, 0, irr_setVisible); - } - - SCM - irr_drawAll (SCM wrapped_obj) - { - if (gui_environment_p (wrapped_obj)) - { - unwrap_gui_environment (wrapped_obj)->drawAll (); - } - else if (scene_manager_p (wrapped_obj)) - { - unwrap_scene_manager (wrapped_obj)->drawAll (); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return SCM_UNSPECIFIED; - } - - SCM - irr_getID (SCM wrapped_obj, - SCM index) - { - if (file_list_p (wrapped_obj)) - { - return scm_from_uint32 (unwrap_file_list (wrapped_obj)->getID (scm_to_uint32 (index))); - } - else if (gui_element_p (wrapped_obj)) - { - return scm_from_int32 (unwrap_gui_element (wrapped_obj)->getID ()); - } - else if (scene_node_p (wrapped_obj)) - { - return scm_from_int32 (unwrap_scene_node (wrapped_obj)->getID ()); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get id from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_getName (SCM wrapped_obj) - { - if (video_driver_p (wrapped_obj)) - { - return scm_from_wide_char_string (unwrap_video_driver (wrapped_obj)->getName ()); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get name from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_getPosition (SCM wrapped_obj, - SCM i) - { - if (cursor_control_p (wrapped_obj)) - { - return irr_gui_getPosition (wrapped_obj); - } - else if (is_scene_node_object (wrapped_obj)) - { - return irr_scene_getPosition (wrapped_obj); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot get position from object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_setMaterial (SCM wrapped_obj, - SCM material) - { - if (video_driver_p (wrapped_obj)) - { - return irr_video_setMaterial (wrapped_obj, material); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set material to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_setMaterialFlag (SCM wrapped_obj, - SCM flag, - SCM newvalue) - { - if (is_scene_node_object (wrapped_obj)) - { - return irr_scene_ISceneNode_setMaterialFlag (wrapped_obj, flag, newvalue); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set material flag to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_setPosition (SCM wrapped_obj, - SCM position) - { - if (cursor_control_p (wrapped_obj)) - { - return irr_gui_setPosition (wrapped_obj, position); - } - else if (is_scene_node_object (wrapped_obj)) - { - return irr_scene_setPosition (wrapped_obj, position); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set position to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - } - - SCM - irr_setVisible (SCM wrapped_obj, - SCM visible) - { -#define SET_VISIBLE(OBJ) OBJ->setVisible (scm_to_bool (visible)); - - if (cursor_control_p (wrapped_obj)) - { - SET_VISIBLE (unwrap_cursor_control (wrapped_obj)); - } - else if (gui_element_p (wrapped_obj)) - { - SET_VISIBLE (unwrap_gui_element (wrapped_obj)); - } - else if (is_scene_node_object (wrapped_obj)) - { - SET_VISIBLE (unwrap_scene_node (wrapped_obj)); - } - else - { - scm_error (scm_arg_type_key, NULL, "Cannot set visibility to object: ~S", - scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); - } - return SCM_UNSPECIFIED; } } diff --git a/src/guile-irrlicht.h b/src/guile-irrlicht.h index 45c02b2..e6276dd 100644 --- a/src/guile-irrlicht.h +++ b/src/guile-irrlicht.h @@ -26,41 +26,8 @@ #include extern "C" { - void init_guile_irrlicht (void); - - SCM - irr_drawAll (SCM wrapped_obj); - - SCM - irr_getID (SCM wrapped_obj, - SCM index); - - SCM - irr_getName (SCM wrapped_obj); - - SCM - irr_getPosition (SCM wrapped_obj, - SCM i); - - SCM - irr_setMaterial (SCM wrapped_obj, - SCM material); - - SCM - irr_setMaterialFlag (SCM wrapped_obj, - SCM flag, - SCM newvalue); - - SCM - irr_setPosition (SCM wrapped_obj, - SCM position); - - SCM - irr_setVisible (SCM wrapped_obj, - SCM visible); - } #endif diff --git a/src/scene-manager.cpp b/src/scene-manager.cpp index dfa58e5..af96eeb 100644 --- a/src/scene-manager.cpp +++ b/src/scene-manager.cpp @@ -38,6 +38,25 @@ #include "vector3d.h" #include "wrapped.h" + SCM + irr_drawAll (SCM wrapped_obj) + { + if (gui_environment_p (wrapped_obj)) + { + unwrap_gui_environment (wrapped_obj)->drawAll (); + } + else if (scene_manager_p (wrapped_obj)) + { + unwrap_scene_manager (wrapped_obj)->drawAll (); + } + else + { + scm_error (scm_arg_type_key, NULL, "Cannot draw all elements from object: ~S", + scm_list_1 (wrapped_obj), scm_list_1 (wrapped_obj)); + } + return SCM_UNSPECIFIED; + } + extern "C" { void