]> git.sesse.net Git - nageru/blob - main.cpp
Yet more fixes for clean shutdown.
[nageru] / main.cpp
1 extern "C" {
2 #include <libavformat/avformat.h>
3 }
4 #include <stdbool.h>
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <epoxy/gl.h>
8
9 #include <QApplication>
10 #include <QCoreApplication>
11 #include <QGL>
12 #include <QSize>
13 #include <QSurfaceFormat>
14
15 #include "context.h"
16 #include "flags.h"
17 #include "image_input.h"
18 #include "mainwindow.h"
19 #include "mixer.h"
20
21 int main(int argc, char *argv[])
22 {
23         parse_flags(argc, argv);
24
25         if (global_flags.va_display.empty() ||
26             global_flags.va_display[0] != '/') {
27                 // We normally use EGL for zerocopy, but if we use VA against DRM
28                 // instead of against X11, we turn it off, and then don't need EGL.
29                 setenv("QT_XCB_GL_INTEGRATION", "xcb_egl", 0);
30         }
31         setlinebuf(stdout);
32         av_register_all();
33
34         QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
35         QApplication app(argc, argv);
36
37         QSurfaceFormat fmt;
38         fmt.setDepthBufferSize(0);
39         fmt.setStencilBufferSize(0);
40         fmt.setProfile(QSurfaceFormat::CoreProfile);
41         fmt.setMajorVersion(3);
42         fmt.setMinorVersion(1);
43         QSurfaceFormat::setDefaultFormat(fmt);
44
45         QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
46
47         global_share_widget = new QGLWidget();
48
49         MainWindow mainWindow;
50         mainWindow.resize(QSize(1500, 810));
51         mainWindow.show();
52
53         app.installEventFilter(&mainWindow);  // For white balance color picking.
54
55         int rc = app.exec();
56         global_mixer->quit();
57         mainWindow.mixer_shutting_down();
58         delete global_mixer;
59         ImageInput::shutdown_updaters();
60         return rc;
61 }