4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 * This is the main entry point for the application
29 #include "Startup.hpp"
31 #include "LocalPath.hpp"
32 #include "Version.hpp"
33 #include "Protection.hpp"
34 #include "Components.hpp"
35 #include "LogFile.hpp"
36 #include "CommandLine.hpp"
37 #include "MainWindow.hpp"
38 #include "Interface.hpp"
40 #include "Look/Fonts.hpp"
41 #include "Screen/Init.hpp"
42 #include "Net/Init.hpp"
43 #include "UtilsSystem.hpp"
44 #include "ResourceLoader.hpp"
45 #include "Language/Language.hpp"
46 #include "Simulator.hpp"
47 #include "OS/Args.hpp"
48 #include "IO/Async/GlobalIOThread.hpp"
51 #include "Thread/Thread.hpp"
55 /* this is necessary on Mac OS X, to let libSDL bootstrap Quartz
56 before entering our main() */
62 static const char *const Usage
= "\n"
63 " -datapath= path to XCSoar data can be defined\n"
64 #ifdef SIMULATOR_AVAILABLE
65 " -simulator bypass startup-screen, use simulator mode directly\n"
66 " -fly bypass startup-screen, use fly mode directly\n"
68 " -profile=fname load profile from file fname\n"
69 #if !defined(_WIN32_WCE)
70 " -WIDTHxHEIGHT use screen resolution WIDTH x HEIGHT\n"
71 " -portrait use a 480x640 screen resolution\n"
72 " -square use a 480x480 screen resolution\n"
73 " -small use a 320x240 screen resolution\n"
75 #if !defined(ANDROID) && !defined(_WIN32_WCE)
76 " -dpi=DPI force usage of DPI for pixel density\n"
77 " -dpi=XDPIxYDPI force usage of XDPI and YDPI for pixel density\n"
79 #ifdef HAVE_CMDLINE_FULLSCREEN
80 " -fullscreen full-screen mode\n"
82 #ifdef HAVE_CMDLINE_RESIZABLE
83 " -resizable resizable window\n"
85 #if defined(_WIN32) && !defined(_WIN32_WCE)&& !defined(__WINE__)
86 " -console open debug output console\n"
91 * Main entry point for the whole XCSoar application
94 int main(int argc
, char **argv
)
97 WinMain(HINSTANCE hInstance
, HINSTANCE hPrevInstance
,
99 gcc_unused LPWSTR lpCmdLine
,
101 gcc_unused LPSTR lpCmdLine2
,
107 ResourceLoader::Init(hInstance
);
112 InitialiseDataPath();
113 StartupLogFreeRamAndStorage();
115 // Write startup note + version to logfile
116 LogFormat(_T("Starting XCSoar %s"), XCSoar_ProductToken
);
118 // Read options from the command line
121 Args
args(GetCommandLine(), Usage
);
123 Args
args(argc
, argv
, Usage
);
125 CommandLine::Parse(args
);
128 ScreenGlobalInit screen_init
;
131 /* try to make the UI most responsive */
132 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL
);
137 InitialiseIOThread();
139 // Perform application initialization and run loop
140 int ret
= EXIT_FAILURE
;
142 ret
= CommonInterface::main_window
->RunEventLoop();
144 delete CommonInterface::main_window
;
146 DeinitialiseIOThread();
150 Fonts::Deinitialize();
152 DeinitialiseDataPath();
155 assert(!ExistsAnyThread());