]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/app.cpp
Fixed random crashes due to QImage corruption.
[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 // Here's the main application loop--short and simple...
24 int main(int argc, char * argv[])
25 {
26         if (argc > 1)
27         {
28                 if (strcmp(argv[1], "--help") == 0)
29                 {
30                         printf("Virtual Jaguar 2.0.0 help\n");
31                         printf("\n");
32                         printf("This is an experimental branch of Virtual Jaguar, how did you get it?\n");
33                         return 0;
34                 }
35         }
36
37         Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
38 //or is it the .qrc filename???
39         // This is so we can pass this stuff using signal/slot mechanism...
40 //ick   int id = qRegisterMetaType<uint32>();
41
42         LogInit("virtualjaguar.log");                           // Init logfile
43         int retVal = -1;                                                        // Default is failure
44
45         // Set up SDL library
46         if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
47         {
48                 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
49         }
50         else
51         {
52                 WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
53                 App app(argc, argv);                                    // Declare an instance of the application
54                 retVal = app.exec();                                    // And run it!
55         }
56
57         LogDone();                                                                      // Close logfile
58         return retVal;
59 }
60
61 // Main app constructor--we stick globally accessible stuff here...
62
63 App::App(int argc, char * argv[]): QApplication(argc, argv)
64 {
65         mainWindow = new MainWin();
66         mainWindow->show();
67 }