Mercurial > projects > mde
comparison 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 |
comparison
equal
deleted
inserted
replaced
82:ac1e3fd07275 | 84:e0f1ec7fe73a |
---|---|
13 You should have received a copy of the GNU General Public License | 13 You should have received a copy of the GNU General Public License |
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
15 | 15 |
16 /** Modular D Engine | 16 /** Modular D Engine |
17 * | 17 * |
18 * This module contains main(), which calls Init and runs the main loop. | 18 * This module contains a minimal main() function. Practically, it is useful for running unittests |
19 * and some other testing. It also serves as a basic example program. | |
19 */ | 20 */ |
20 module mde.mde; | 21 module mde.mde; |
21 | 22 |
22 // Comment to show use, where only used minimally: | |
23 | |
24 import mde.imde; // this module's interface for external modules | 23 import mde.imde; // this module's interface for external modules |
25 import mde.events; // pollEvents | 24 import mde.events; // pollEvents() // NOTE: Must be imported before Init, otherwise fonts don't display properly (why??) |
25 import mde.setup.Init; // initialization | |
26 import mde.lookup.Options; // pollInterval option | 26 import mde.lookup.Options; // pollInterval option |
27 | 27 import mde.scheduler.Scheduler; // mainSchedule |
28 import gl = mde.gl.draw; // gl.draw() | 28 import gl = mde.gl.draw; // gl.draw() |
29 import mde.input.Input; // new Input() | |
30 | |
31 import mde.setup.Init; | |
32 import mde.scheduler.Scheduler; // Scheduler.run() | |
33 import mde.setup.exception; // InitException | |
34 | 29 |
35 import tango.core.Thread : Thread; // Thread.sleep() | 30 import tango.core.Thread : Thread; // Thread.sleep() |
36 import tango.time.Clock; // Clock.now() | 31 import tango.time.Clock; // Clock.now() |
37 import tango.util.log.Log : Log, Logger; | 32 import tango.util.log.Log : Log, Logger; |
38 debug (mdeUnitTest) { | 33 debug (mdeUnitTest) { |
40 import mde.file.mergetag.mdeUT; | 35 import mde.file.mergetag.mdeUT; |
41 } | 36 } |
42 | 37 |
43 int main(char[][] args) | 38 int main(char[][] args) |
44 { | 39 { |
45 //BEGIN Initialisation | 40 // If compiled with unittests, notify that they completed and exit: |
46 Logger logger = Log.getLogger ("mde.mde"); | |
47 debug (mdeUnitTest) { | 41 debug (mdeUnitTest) { |
42 Logger logger = Log.getLogger ("mde.mde"); | |
48 logger.info ("Compiled unittests have completed; terminating."); | 43 logger.info ("Compiled unittests have completed; terminating."); |
49 return 0; | 44 return 0; |
50 } | 45 } |
51 | 46 |
52 scope Init init; | 47 scope Init init = new Init(args); // initialize mde |
53 try { | |
54 init = new Init(args); // initialisation | |
55 } catch (InitException e) { | |
56 logger.fatal ("Initialisation failed: " ~ e.msg); | |
57 return 1; | |
58 } | |
59 | 48 |
49 // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range | |
60 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0) | 50 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0) |
61 miscOpts.set!(double) ("pollInterval", 0.01); | 51 miscOpts.set!(double) ("pollInterval", 0.01); |
62 //END Initialisation | |
63 | 52 |
64 //BEGIN Main loop setup | 53 //BEGIN Main loop setup |
65 /* Note: the main loop is currently controlled by the scheduler. This is not really ideal, | 54 /* Note: the main loop is currently controlled by the scheduler. This is not really ideal, |
66 * since it provides no direct control of the order in which components are executed and does | 55 * since it provides no direct control of the order in which components are executed and does |
67 * not allow running components simultaeneously with threads. | 56 * not allow running components simultaeneously with threads. |