]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/app.cpp
Small fix to allow app.cpp to compile on win32.
[virtualjaguar] / src / gui / app.cpp
1 //
2 // app.cpp - Qt-based GUI for Virtual Jaguar
3 //
4 // by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -------------------------------------------------------------
11 // JLH  12/23/2009  Created this file
12 // JLH  01/21/2011  Added SDL initialization
13 //
14
15 #include "app.h"
16
17 #include <SDL.h>
18 #include <QApplication>
19 #include "log.h"
20 #include "mainwin.h"
21 #include "types.h"
22
23 // Apparently on other archs, SDL is hijacking main, so let's do this:
24 #undef main
25
26 // Here's the main application loop--short and simple...
27 int main(int argc, char * argv[])
28 {
29         if (argc > 1)
30         {
31                 if (strcmp(argv[1], "--help") == 0)
32                 {
33                         printf("Virtual Jaguar 2.0.0 help\n");
34                         printf("\n");
35                         printf("This is an experimental branch of Virtual Jaguar, how did you get it?\n");
36                         return 0;
37                 }
38         }
39
40         Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
41 //or is it the .qrc filename???
42         // This is so we can pass this stuff using signal/slot mechanism...
43 //ick   int id = qRegisterMetaType<uint32>();
44
45         LogInit("virtualjaguar.log");                           // Init logfile
46         int retVal = -1;                                                        // Default is failure
47
48         // Set up SDL library
49         if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
50         {
51                 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
52         }
53         else
54         {
55                 WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
56                 App app(argc, argv);                                    // Declare an instance of the application
57                 retVal = app.exec();                                    // And run it!
58         }
59
60         LogDone();                                                                      // Close logfile
61         return retVal;
62 }
63
64 // Main app constructor--we stick globally accessible stuff here...
65
66 App::App(int argc, char * argv[]): QApplication(argc, argv)
67 {
68         mainWindow = new MainWin();
69         mainWindow->show();
70 }