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