Mercurial > projects > mde
comparison mde/mde.d @ 83:2813ac68576f
Start of creating a separate gui demo module and leaving mde.d for testing.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 30 Aug 2008 10:54:32 +0100 |
parents | 25cb7420dc91 |
children | e0f1ec7fe73a |
comparison
equal
deleted
inserted
replaced
80:ea58f277f487 | 83:2813ac68576f |
---|---|
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.setup.Init; // initialization |
26 import mde.lookup.Options; // pollInterval option | 25 import mde.lookup.Options; // pollInterval option |
27 | 26 import mde.scheduler.Scheduler; // mainSchedule |
27 import mde.events; // pollEvents() | |
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 | 33 |
39 int main(char[][] args) | 34 int main(char[][] args) |
40 { | 35 { |
41 //BEGIN Initialisation | 36 // If compiled with unittests, notify that they completed and exit: |
42 Logger logger = Log.getLogger ("mde.mde"); | |
43 debug (mdeUnitTest) { | 37 debug (mdeUnitTest) { |
38 Logger logger = Log.getLogger ("mde.mde"); | |
44 logger.info ("Compiled unittests have completed; terminating."); | 39 logger.info ("Compiled unittests have completed; terminating."); |
45 return 0; | 40 return 0; |
46 } | 41 } |
47 | 42 |
48 scope Init init; | 43 scope Init init = new Init(args); // initialize mde |
49 try { | |
50 init = new Init(args); // initialisation | |
51 } catch (InitException e) { | |
52 logger.fatal ("Initialisation failed: " ~ e.msg); | |
53 return 1; | |
54 } | |
55 | 44 |
45 // Make sure pollInterval has a sane value. FIXME: get Options class to enforce range | |
56 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0) | 46 if (miscOpts.pollInterval !<= 1.0 || miscOpts.pollInterval !>= 0.0) |
57 miscOpts.set!(double) ("pollInterval", 0.01); | 47 miscOpts.set!(double) ("pollInterval", 0.01); |
58 //END Initialisation | |
59 | 48 |
60 //BEGIN Main loop setup | 49 //BEGIN Main loop setup |
61 /* Note: the main loop is currently controlled by the scheduler. This is not really ideal, | 50 /* Note: the main loop is currently controlled by the scheduler. This is not really ideal, |
62 * since it provides no direct control of the order in which components are executed and does | 51 * since it provides no direct control of the order in which components are executed and does |
63 * not allow running components simultaeneously with threads. | 52 * not allow running components simultaeneously with threads. |