From: Javier Sancho Date: Thu, 28 Mar 2019 08:50:12 +0000 (+0100) Subject: Build with irrlicht X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=b201086ac53a63e010f23a7ec9128013fe3ac385;p=dungeon-master.git Build with irrlicht --- diff --git a/configure.ac b/configure.ac index 07f875c..94780b7 100644 --- a/configure.ac +++ b/configure.ac @@ -6,9 +6,16 @@ AC_LANG([C++]) PKG_CHECK_MODULES([GUILE], [guile-2.2]) +AC_CHECK_LIB( + [Irrlicht], + [createDevice], + [], + AC_MSG_ERROR([Missing Irrlicht lib. Try option --with-irrlicht-lib]) +) + AC_CONFIG_FILES([ - Makefile - src/Makefile + Makefile + src/Makefile ]) AC_OUTPUT diff --git a/src/main.cpp b/src/main.cpp index 3a76eaf..6c2e2a7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,5 +9,59 @@ int main() { scm_init_guile(); scm_primitive_load(scm_from_locale_string("plugins/default/main.scm")); + + IrrlichtDevice* device = + createDevice(EDT_OPENGL, + dimension2d(640, 480), 16, + false, false, false, 0); + if (!device) + return 1; + + IVideoDriver* driver = device->getVideoDriver(); + + f32 bg_r = 255.0f; + f32 bg_g = 255.0f; + f32 bg_b = 255.0f; + + bool fadeOut = -1; + + u32 then = device->getTimer()->getTime(); + + const f32 fadeRate = 0.1f; + + while (device->run()) + { + const u32 now = device->getTimer()->getTime(); + const f32 frameDeltaTime = (f32)(now - then); + then = now; + + if (bg_r <= 0.0f) fadeOut = false; + else if (bg_r >= 255.0f) fadeOut = true; + + if (fadeOut) + { + bg_r -= fadeRate * frameDeltaTime; + bg_g -= fadeRate * frameDeltaTime; + bg_b -= fadeRate * frameDeltaTime; + } + else + { + bg_r += fadeRate * frameDeltaTime; + bg_g += fadeRate * frameDeltaTime; + bg_b += fadeRate * frameDeltaTime; + } + + if (bg_r <= 0.0f) + bg_r = bg_b = bg_g = 0.0f; + else if (bg_r >= 255.0f) + bg_r = bg_b = bg_g = 255.0f; + + driver->beginScene(true, true, SColor(255, (u32)bg_r, + (u32)bg_g, (u32)bg_b)); + driver->endScene(); + } + + device->drop(); + return 0; }