X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=main.cpp;h=0f1e6fa1eead8ca1eabacce3cc5fb2d10f44944c;hb=258fa13eda2ee6b41ad2fd8c530a6b5a8b9571fe;hp=ad42075363054145fc23d80777b43b1c90f3ca8b;hpb=a8640fb1324d3148ebe9337e000189f9ca54f4de;p=nageru diff --git a/main.cpp b/main.cpp index ad42075..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,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) {