From 704cf6c2cc3d308c625071f6e03bd20ed2d833f8 Mon Sep 17 00:00:00 2001 From: Javier Sancho Date: Tue, 17 Mar 2020 12:10:35 +0100 Subject: [PATCH] begin-scene --- Makefile.am | 1 + irrlicht/video.scm | 18 +++++++++++++++++- src/color.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/color.h | 35 +++++++++++++++++++++++++++++++++++ src/video-driver.cpp | 25 +++++++++++++++++++++++++ src/video-driver.h | 8 ++++++++ 6 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/color.cpp create mode 100644 src/color.h diff --git a/Makefile.am b/Makefile.am index a1b6055..e1d88a1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,7 @@ libguile_irrlicht_la_SOURCES = \ src/animated-mesh-md2.cpp \ src/animated-mesh-scene-node.cpp \ src/camera-scene-node.cpp \ + src/color.cpp \ src/device.cpp \ src/dimension2d.cpp \ src/driver-types.cpp \ diff --git a/irrlicht/video.scm b/irrlicht/video.scm index 77e3d21..9999595 100644 --- a/irrlicht/video.scm +++ b/irrlicht/video.scm @@ -19,6 +19,22 @@ (define-module (irrlicht video) - #:export (get-texture)) + #:export (begin-scene + get-texture)) (load-extension "libguile-irrlicht" "init_guile_irrlicht") + +(define irr-begin-scene begin-scene) +(define* (begin-scene video-driver + #:key + (back-buffer #t) + (z-buffer #t) + (color '(255 0 0 0)) + (video-data #f) + (source-rect #f)) + (irr-begin-scene video-driver + back-buffer + z-buffer + color + video-data + source-rect)) diff --git a/src/color.cpp b/src/color.cpp new file mode 100644 index 0000000..a6879c3 --- /dev/null +++ b/src/color.cpp @@ -0,0 +1,38 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#include +#include +#include "rect.h" + +extern "C" { + + irr::video::SColor + scm_to_color (SCM color) + { + return irr::video::SColor + (scm_to_uint32 (scm_car (color)), + scm_to_uint32 (scm_cadr (color)), + scm_to_uint32 (scm_caddr (color)), + scm_to_uint32 (scm_cadddr (color))); + } + +} diff --git a/src/color.h b/src/color.h new file mode 100644 index 0000000..d85513b --- /dev/null +++ b/src/color.h @@ -0,0 +1,35 @@ +/* guile-irrlicht --- GNU Guile bindings for Irrlicht Engine + + Copyright (C) 2020 Javier Sancho + + This file is part of guile-irrlicht. + + guile-irrlicht is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + guile-irrlicht is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with guile-irrlicht. If not, see + . +*/ + +#ifndef __GUILE_IRRLICHT_COLOR_H_INCLUDED__ +#define __GUILE_IRRLICHT_COLOR_H_INCLUDED__ + +#include +#include + +extern "C" { + + irr::video::SColor + scm_to_color (SCM color); + +} + +#endif diff --git a/src/video-driver.cpp b/src/video-driver.cpp index 632f0de..dc9cce6 100644 --- a/src/video-driver.cpp +++ b/src/video-driver.cpp @@ -22,7 +22,9 @@ #include #include +#include "color.h" #include "device.h" +#include "rect.h" #include "texture.h" #include "video-driver.h" #include "wrapped.h" @@ -33,6 +35,7 @@ extern "C" { init_video_driver (void) { init_video_driver_type (); + scm_c_define_gsubr ("begin-scene", 6, 0, 0, (scm_t_subr)irr_video_beginScene); 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); } @@ -41,6 +44,28 @@ extern "C" { init_video_driver_type, video_driver_p, wrap_video_driver, unwrap_video_driver); + SCM + irr_video_beginScene (SCM wrapped_video_driver, + SCM back_buffer, + SCM z_buffer, + SCM color, + SCM video_data, + SCM source_rect) + { + irr::video::IVideoDriver* driver = unwrap_video_driver (wrapped_video_driver); + irr::core::rect* sourceRectAddress = 0; + if (!scm_is_false (source_rect)) + { + irr::core::rect sourceRect = scm_to_rect_s32 (source_rect); + sourceRectAddress = &sourceRect; + } + return scm_from_bool (driver->beginScene (scm_to_bool (back_buffer), + scm_to_bool (z_buffer), + scm_to_color (color), + irr::video::SExposedVideoData (), + sourceRectAddress)); + } + SCM irr_video_getTexture (SCM wrapped_video_driver, SCM filename) diff --git a/src/video-driver.h b/src/video-driver.h index 5137ca4..65df39a 100644 --- a/src/video-driver.h +++ b/src/video-driver.h @@ -34,6 +34,14 @@ extern "C" { DECLARE_WRAPPED_TYPE (irr::video::IVideoDriver*, init_video_driver_type, video_driver_p, wrap_video_driver, unwrap_video_driver); + SCM + irr_video_beginScene (SCM wrapped_video_driver, + SCM back_buffer, + SCM z_buffer, + SCM color, + SCM video_data, + SCM source_rect); + SCM irr_video_getTexture (SCM wrapped_video_driver, SCM filename); -- 2.39.2