]> git.sesse.net Git - nageru/blobdiff - glwidget.cpp
Hook up the preview window to a different chain.
[nageru] / glwidget.cpp
index 1e676405e6258b1f62eea1cbf764faaf7f39a6ac..3fb4889dc314c7ce163d389477926dfe110d51bc 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <movit/resource_pool.h>
 #include <stdio.h>
+#include <mutex>
 
 #include "context.h"
 #include "mixer.h"
@@ -38,11 +39,14 @@ void GLWidget::initializeGL()
        printf("egl context=%p\n", eglGetCurrentContext());
        //printf("threads: %p %p\n", QThread::currentThread(), qGuiApp->thread());
 
-       global_mixer = new Mixer(QGLFormat::toSurfaceFormat(format()));
-       global_mixer->set_frame_ready_callback(Mixer::OUTPUT_LIVE, [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);
@@ -93,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(Mixer::OUTPUT_LIVE, &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;