From: Javier Sancho Date: Sat, 21 Mar 2020 19:39:29 +0000 (+0100) Subject: get-fps X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=af6316437363cf85ac844091071bee9b04f58a31;p=guile-irrlicht.git get-fps --- diff --git a/src/misc.cpp b/src/misc.cpp index bd3e037..1c01d2c 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -24,8 +24,10 @@ #include "cursor-control.h" #include "gui-element.h" +#include "gui-environment.h" #include "mesh-scene-node.h" #include "misc.h" +#include "scene-manager.h" #include "scene-node.h" #include "video-driver.h" #include "wchar.h" @@ -35,10 +37,30 @@ extern "C" { void init_misc (void) { + scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll); scm_c_define_gsubr ("get-name", 1, 0, 0, (scm_t_subr)irr_getName); scm_c_define_gsubr ("set-position!", 2, 0, 0, (scm_t_subr)irr_setPosition); scm_c_define_gsubr ("set-visible!", 2, 0, 0, (scm_t_subr)irr_setVisible); - scm_c_export ("get-name", "set-position!", "set-visible!", NULL); + scm_c_export ("draw-all", "get-name", "set-position!", "set-visible!", NULL); + } + + 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 diff --git a/src/misc.h b/src/misc.h index d7c7b27..047512d 100644 --- a/src/misc.h +++ b/src/misc.h @@ -30,6 +30,9 @@ extern "C" { void init_misc (void); + SCM + irr_drawAll (SCM wrapped_obj); + SCM irr_getName (SCM wrapped_obj); diff --git a/src/video-driver.cpp b/src/video-driver.cpp index 43ada62..ee80c36 100644 --- a/src/video-driver.cpp +++ b/src/video-driver.cpp @@ -38,11 +38,11 @@ extern "C" { { init_video_driver_type (); scm_c_define_gsubr ("begin-scene", 1, 0, 1, (scm_t_subr)irr_video_beginScene); - scm_c_define_gsubr ("draw-all", 1, 0, 0, (scm_t_subr)irr_drawAll); scm_c_define_gsubr ("end-scene", 1, 0, 0, (scm_t_subr)irr_video_endScene); + scm_c_define_gsubr ("get-fps", 1, 0, 0, (scm_t_subr)irr_video_getFPS); scm_c_define_gsubr ("get-texture", 2, 0, 0, (scm_t_subr)irr_video_getTexture); scm_c_define_gsubr ("get-video-driver", 1, 0, 0, (scm_t_subr)irr_getVideoDriver); - scm_c_export ("begin-scene", "draw-all", "end-scene", "get-texture", + scm_c_export ("begin-scene", "end-scene", "get-fps", "get-texture", "get-video-driver", NULL); } @@ -86,29 +86,17 @@ extern "C" { } SCM - irr_drawAll (SCM wrapped_obj) + irr_video_endScene (SCM wrapped_video_driver) { - 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; + irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver); + return scm_from_bool (driver->endScene ()); } SCM - irr_video_endScene (SCM wrapped_video_driver) + irr_video_getFPS (SCM wrapped_video_driver) { irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver); - return scm_from_bool (driver->endScene ()); + return scm_from_int32 (driver->getFPS ()); } SCM diff --git a/src/video-driver.h b/src/video-driver.h index d8cd754..2560135 100644 --- a/src/video-driver.h +++ b/src/video-driver.h @@ -39,10 +39,10 @@ extern "C" { SCM rest); SCM - irr_drawAll (SCM wrapped_obj); + irr_video_endScene (SCM wrapped_video_driver); SCM - irr_video_endScene (SCM wrapped_video_driver); + irr_video_getFPS (SCM wrapped_video_driver); SCM irr_video_getTexture (SCM wrapped_video_driver,