X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=main.cpp;h=0f1e6fa1eead8ca1eabacce3cc5fb2d10f44944c;hb=37ed9122ae6d6e207439c73115810db47cdea490;hp=a0e93420688acebd0e742d2632b10b4a6cd2733b;hpb=d9913b0d39d6ea0362f31157e5979ffa351f3888;p=nageru diff --git a/main.cpp b/main.cpp index a0e9342..0f1e6fa 100644 --- a/main.cpp +++ b/main.cpp @@ -39,6 +39,7 @@ string filename_for_frame(unsigned stream_idx, int64_t pts) mutex frame_mu; vector frames[MAX_STREAMS]; +QGLWidget *global_share_widget; int record_thread_func(); @@ -47,12 +48,33 @@ 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(); thread(record_thread_func).detach(); - start_player_thread(); return app.exec(); } @@ -77,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) { @@ -95,6 +117,8 @@ int record_thread_func() global_mainwindow->ui->input2_display->setFrame(pkt.stream_index, pkt.pts); } else if (pkt.stream_index == 2) { global_mainwindow->ui->input3_display->setFrame(pkt.stream_index, pkt.pts); + } else if (pkt.stream_index == 3) { + global_mainwindow->ui->input4_display->setFrame(pkt.stream_index, pkt.pts); } });