]> git.sesse.net Git - nageru/blobdiff - main.cpp
Refactor FBO creation. A step on the way to persistent FBOs and temporary textures.
[nageru] / main.cpp
index ad42075363054145fc23d80777b43b1c90f3ca8b..0f1e6fa1eead8ca1eabacce3cc5fb2d10f44944c 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -39,6 +39,7 @@ string filename_for_frame(unsigned stream_idx, int64_t pts)
 
 mutex frame_mu;
 vector<int64_t> frames[MAX_STREAMS];
+QGLWidget *global_share_widget;
 
 int record_thread_func();
 
@@ -47,7 +48,29 @@ int main(int argc, char **argv)
        av_register_all();
        avformat_network_init();
 
+       QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
+
+       QSurfaceFormat fmt;
+       fmt.setDepthBufferSize(0);
+       fmt.setStencilBufferSize(0);
+       fmt.setProfile(QSurfaceFormat::CoreProfile);
+       fmt.setMajorVersion(3);
+       fmt.setMinorVersion(1);
+
+       // Turn off vsync, since Qt generally gives us at most frame rate
+       // (display frequency) / (number of QGLWidgets active).
+       fmt.setSwapInterval(0);
+
+       QSurfaceFormat::setDefaultFormat(fmt);
+
+       QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
+
        QApplication app(argc, argv);
+       global_share_widget = new QGLWidget();
+       if (!global_share_widget->isValid()) {
+               fprintf(stderr, "Failed to initialize OpenGL. Futatabi needs at least OpenGL 3.1 to function properly.\n");
+               exit(1);
+       }
        MainWindow mainWindow;
        mainWindow.show();
 
@@ -76,8 +99,8 @@ int record_thread_func()
                if (av_read_frame(format_ctx.get(), &pkt) != 0) {
                        break;
                }
-               fprintf(stderr, "Got a frame from camera %d, pts = %ld, size = %d\n",
-                       pkt.stream_index, pkt.pts, pkt.size);
+               //fprintf(stderr, "Got a frame from camera %d, pts = %ld, size = %d\n",
+               //      pkt.stream_index, pkt.pts, pkt.size);
                string filename = filename_for_frame(pkt.stream_index, pkt.pts);
                FILE *fp = fopen(filename.c_str(), "wb");
                if (fp == nullptr) {