]> git.jsancho.org Git - dungeon-master.git/commitdiff
Build with irrlicht
authorJavier Sancho <jsf@jsancho.org>
Thu, 28 Mar 2019 08:50:12 +0000 (09:50 +0100)
committerJavier Sancho <jsf@jsancho.org>
Thu, 28 Mar 2019 08:50:12 +0000 (09:50 +0100)
configure.ac
src/main.cpp

index 07f875c44a3814d7b84016a46da730f934efa98f..94780b7b2167e160c1d7be5a7a5a7c4b7795905e 100644 (file)
@@ -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
index 3a76eaf70c2f6c3944d95046f4518ff1c491b3ef..6c2e2a756dc856903df78a4bf80b0e0e3cb6decc 100644 (file)
@@ -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<u32>(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;
 }