2 #include <libavformat/avformat.h>
8 #include <epoxy/gl.h> // IWYU pragma: keep
9 #include <QApplication>
10 #include <QCoreApplication>
13 #include <QSurfaceFormat>
18 #include "image_input.h"
19 #include "mainwindow.h"
22 int main(int argc, char *argv[])
24 parse_flags(argc, argv);
26 if (global_flags.va_display.empty() ||
27 global_flags.va_display[0] != '/') {
28 // We normally use EGL for zerocopy, but if we use VA against DRM
29 // instead of against X11, we turn it off, and then don't need EGL.
30 setenv("QT_XCB_GL_INTEGRATION", "xcb_egl", 0);
36 QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
37 QApplication app(argc, argv);
40 fmt.setDepthBufferSize(0);
41 fmt.setStencilBufferSize(0);
42 fmt.setProfile(QSurfaceFormat::CoreProfile);
43 fmt.setMajorVersion(3);
44 fmt.setMinorVersion(1);
46 // Turn off vsync, since Qt generally gives us at most frame rate
47 // (display frequency) / (number of QGLWidgets active).
48 fmt.setSwapInterval(0);
50 QSurfaceFormat::setDefaultFormat(fmt);
52 QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
54 global_share_widget = new QGLWidget();
56 MainWindow mainWindow;
57 mainWindow.resize(QSize(1500, 850));
60 app.installEventFilter(&mainWindow); // For white balance color picking.
62 // Even on an otherwise unloaded system, it would seem writing the recording
63 // to disk (potentially terabytes of data as time goes by) causes Nageru
64 // to be pushed out of RAM. If we have the right privileges, simply lock us
65 // into memory for better realtime behavior.
66 if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
68 fprintf(stderr, "Failed to lock Nageru into RAM. You probably want to\n");
69 fprintf(stderr, "increase \"memlock\" for your user in limits.conf\n");
70 fprintf(stderr, "for better realtime behavior.\n");
78 mainWindow.mixer_shutting_down();
80 ImageInput::shutdown_updaters();