X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=glwidget.cpp;h=3fb4889dc314c7ce163d389477926dfe110d51bc;hb=6796837c2e3e08de8d530be233317a2fc4a43f72;hp=b754ddcf29c68f55ca2c912b92967927a130a75d;hpb=08a7f1e36a4e59183b8b87f8a699f380cda12788;p=nageru diff --git a/glwidget.cpp b/glwidget.cpp index b754ddc..3fb4889 100644 --- a/glwidget.cpp +++ b/glwidget.cpp @@ -11,6 +11,7 @@ #include #include +#include #include "context.h" #include "mixer.h" @@ -38,16 +39,14 @@ void GLWidget::initializeGL() printf("egl context=%p\n", eglGetCurrentContext()); //printf("threads: %p %p\n", QThread::currentThread(), qGuiApp->thread()); - QSurfaceFormat fmt = QGLFormat::toSurfaceFormat(format()); - QSurface *surface = create_surface(fmt); - QSurface *surface2 = create_surface(fmt); - QSurface *surface3 = create_surface(fmt); - QSurface *surface4 = create_surface(fmt); - global_mixer = new Mixer(surface, surface2, surface3, surface4); - global_mixer->set_frame_ready_fallback([this]{ + static std::once_flag flag; + std::call_once(flag, [this]{ + global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format())); + global_mixer->start(); + }); + global_mixer->set_frame_ready_callback(output, [this]{ QMetaObject::invokeMethod(this, "update", Qt::AutoConnection); }); - global_mixer->start(); // Prepare the shaders to actually get the texture shown (ick). glDisable(GL_BLEND); @@ -98,12 +97,13 @@ void GLWidget::initializeGL() void GLWidget::resizeGL(int width, int height) { glViewport(0, 0, width, height); + global_mixer->set_preview_size(output, width, height); } void GLWidget::paintGL() { Mixer::DisplayFrame frame; - if (!global_mixer->get_display_frame(&frame)) { + if (!global_mixer->get_display_frame(output, &frame)) { glClearColor(0.0f, 1.0f, 0.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); return;