creaturesImage work: add mutableCopy and tint methods to the base class (and change...
[openc2e.git] / main.cpp
blob228bb4b84134a83364358daebc3cb81dde2c11a0
1 /*
2 * main.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Wed 02 Jun 2004.
6 * Copyright (c) 2004-2008 Alyssa Milburn. All rights reserved.
7 * Copyright (c) 2005-2008 Bryan Donlan. All rights reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
21 #include "openc2e.h"
22 #include <iostream>
23 #include "Engine.h"
24 #include "SDLBackend.h"
25 #ifdef OPENAL_SUPPORT
26 #include "OpenALBackend.h"
27 #endif
28 #ifdef QT_SUPPORT
29 #include "qtgui/QtBackend.h"
30 #endif
32 #ifdef _WIN32
33 #include <windows.h>
34 #undef main
35 #endif
37 extern "C" int main(int argc, char *argv[]) {
38 try {
39 std::cout << "openc2e (development build), built " __DATE__ " " __TIME__ "\nCopyright (c) 2004-2008 Alyssa Milburn and others\n\n";
41 engine.addPossibleBackend("sdl", shared_ptr<Backend>(new SDLBackend()));
42 #ifdef QT_SUPPORT
43 boost::shared_ptr<QtBackend> qtbackend = boost::shared_ptr<QtBackend>(new QtBackend());
44 boost::shared_ptr<Backend> qtbackend_generic = boost::dynamic_pointer_cast<class Backend, class QtBackend>(qtbackend);
45 engine.addPossibleBackend("qt", qtbackend_generic); // last-added backend is default
46 #endif
47 #ifdef OPENAL_SUPPORT
48 engine.addPossibleAudioBackend("openal", shared_ptr<AudioBackend>(new OpenALBackend()));
49 #endif
51 // pass command-line flags to the engine, but do no other setup
52 if (!engine.parseCommandLine(argc, argv)) return 1;
54 // get the engine to do all the startup (read catalogue, loading world, etc)
55 if (!engine.initialSetup()) return 0;
57 int ret = engine.backend->run(argc, argv);
59 // we're done, be sure to shut stuff down
60 engine.shutdown();
62 return ret;
63 } catch (std::exception &e) {
64 #ifdef _WIN32
65 MessageBox(NULL, e.what(), "openc2e - Fatal exception encountered:", MB_ICONERROR);
66 #else
67 std::cerr << "Fatal exception encountered: " << e.what() << "\n";
68 #endif
69 return 1;
73 /* vim: set noet: */