From 4590365d48d5af4b16f64279bcef89cfe340506f Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Thu, 19 Mar 2020 13:15:58 +0100 Subject: [PATCH] draw-all end-scene --- examples/01.HelloWorld.scm | 4 ++-- src/video-driver.cpp | 33 ++++++++++++++++++++++++++++++++- src/video-driver.h | 6 ++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/examples/01.HelloWorld.scm b/examples/01.HelloWorld.scm index 8cbe11e..b480c89 100644 --- a/examples/01.HelloWorld.scm +++ b/examples/01.HelloWorld.scm @@ -63,8 +63,8 @@ ;; draw everything (while (run device) (begin-scene driver #:color '(255 100 101 140)) - (scene-draw-all scene-manager) - (gui-draw-all gui-env) + (draw-all scene-manager) + (draw-all gui-env) (end-scene driver)) ;; delete device diff --git a/src/video-driver.cpp b/src/video-driver.cpp index 57231a6..c811c18 100644 --- a/src/video-driver.cpp +++ b/src/video-driver.cpp @@ -24,7 +24,9 @@ #include "color.h" #include "device.h" +#include "gui-environment.h" #include "rect.h" +#include "scene-manager.h" #include "texture.h" #include "video-driver.h" #include "wrapped.h" @@ -36,9 +38,12 @@ 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_guiscene_drawAll); + scm_c_define_gsubr ("end-scene", 1, 0, 0, (scm_t_subr)irr_video_endScene); 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", "get-texture", "get-video-driver", NULL); + scm_c_export ("begin-scene", "draw-all", "end-scene", "get-texture", + "get-video-driver", NULL); } DEFINE_WRAPPED_TYPE (irr::video::IVideoDriver*, "video-driver", @@ -80,6 +85,32 @@ extern "C" { sourceRectAddress)); } + SCM + irr_guiscene_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_video_endScene (SCM wrapped_video_driver) + { + irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver); + return scm_from_bool (driver->endScene ()); + } + SCM irr_video_getTexture (SCM wrapped_video_driver, SCM filename) diff --git a/src/video-driver.h b/src/video-driver.h index 64bf068..0957836 100644 --- a/src/video-driver.h +++ b/src/video-driver.h @@ -38,6 +38,12 @@ extern "C" { irr_video_beginScene (SCM wrapped_video_driver, SCM rest); + SCM + irr_guiscene_drawAll (SCM wrapped_obj); + + SCM + irr_video_endScene (SCM wrapped_video_driver); + SCM irr_video_getTexture (SCM wrapped_video_driver, SCM filename); -- 2.39.5