+
+ // Shared procedures (used by two or more objects)
+ DEFINE_GSUBR ("draw-all", 1, 0, 0, irr_drawAll);
+ DEFINE_GSUBR ("get-name", 1, 0, 0, irr_getName);
+ 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_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_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 (mesh_scene_node_p (wrapped_obj) || scene_node_p (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 (scene_node_p (wrapped_obj) || mesh_scene_node_p (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)
+ {
+ if (cursor_control_p (wrapped_obj))
+ {
+ unwrap_cursor_control (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ else if (gui_element_p (wrapped_obj))
+ {
+ unwrap_gui_element (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ else if (scene_node_p (wrapped_obj))
+ {
+ unwrap_scene_node (wrapped_obj)->setVisible (scm_to_bool (visible));
+ }
+ 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;