diff mde/mde.d @ 84:e0f1ec7fe73a

Merge plus a few tweaks.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 31 Aug 2008 15:59:17 +0100
parents ac1e3fd07275 2813ac68576f
children 56c0ddd90193
line wrap: on
line diff
--- a/mde/mde.d	Sat Aug 30 09:37:35 2008 +0100
+++ b/mde/mde.d	Sun Aug 31 15:59:17 2008 +0100
@@ -15,22 +15,17 @@
 
 /** Modular D Engine
  *
- * This module contains main(), which calls Init and runs the main loop.
+ * This module contains a minimal main() function. Practically, it is useful for running unittests
+ * and some other testing. It also serves as a basic example program.
  */
 module mde.mde;
 
-// Comment to show use, where only used minimally:
-
 import mde.imde;                        // this module's interface for external modules
-import mde.events;                      // pollEvents
+import mde.events;      // pollEvents() // NOTE: Must be imported before Init, otherwise fonts don't display properly (why??)
+import mde.setup.Init;                  // initialization
 import mde.lookup.Options;              // pollInterval option
-
+import mde.scheduler.Scheduler;         // mainSchedule
 import gl = mde.gl.draw;                // gl.draw()
-import mde.input.Input;                 // new Input()
-
-import mde.setup.Init;
-import mde.scheduler.Scheduler;         // Scheduler.run()
-import mde.setup.exception;             // InitException
 
 import tango.core.Thread : Thread;	// Thread.sleep()
 import tango.time.Clock;                // Clock.now()
@@ -42,24 +37,18 @@
 
 int main(char[][] args)
 {
-    //BEGIN Initialisation
-    Logger logger = Log.getLogger ("mde.mde");
+    // If compiled with unittests, notify that they completed and exit:
     debug (mdeUnitTest) {
+        Logger logger = Log.getLogger ("mde.mde");
         logger.info ("Compiled unittests have completed; terminating.");
         return 0;
     }
     
-    scope Init init;
-    try {
-        init = new Init(args);	// initialisation
-    } catch (InitException e) {
-        logger.fatal ("Initialisation failed: " ~ e.msg);
-        return 1;
-    }
+    scope Init init = new Init(args);	// initialize mde
     
+    // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range
     if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0)
         miscOpts.set!(double) ("pollInterval", 0.01);
-    //END Initialisation
     
     //BEGIN Main loop setup
     /* Note: the main loop is currently controlled by the scheduler. This is not really ideal,