#include <movit/resource_pool.h>
#include <stdio.h>
+#include <mutex>
#include "context.h"
#include "mixer.h"
printf("egl context=%p\n", eglGetCurrentContext());
//printf("threads: %p %p\n", QThread::currentThread(), qGuiApp->thread());
- GLWidget *t = this;
- global_mixer->set_frame_ready_fallback([t]{
- QMetaObject::invokeMethod(t, "update", Qt::AutoConnection);
+ 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);
});
-
- 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;
- global_mixer->start(surface, surface2, surface3, surface4);
// Prepare the shaders to actually get the texture shown (ick).
glDisable(GL_BLEND);
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;