How to update gui and render to opengl simultaneously without stutter
Unsolved
General and Desktop
-
wrote on 1 Jul 2024, 18:33 last edited by wakiki 7 Jan 2024, 18:42
In my app i get information from different worker threads via signal-slot and write them in my widgets every 500ms:
m_timer->setInterval(500); QObject::connect(m_timer, &QTimer::timeout, this, &SystemManager::update); void SystemManager::update() { m_tabWidget->process(); //update gui such as QLineSeries::replace or QTableWidgetItem::setText }
In an additional window i have a QOpenGLWindow running (i also tried with QOpenGlWidget with same results), which renders animated objects in ~120fps.
GlWindow::GlWindow(QWidget *parent) : QOpenGLWindow() { QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QSurfaceFormat format;// = QSurfaceFormat::defaultFormat(); format.setSwapInterval(0); //vsync on = 1, vsync off = 0 ... QObject::connect(m_repaintTimer, SIGNAL(timeout()), this, SLOT(update())); } void GlWindow::initializeGL() { initializeOpenGLFunctions(); ... const double targetFrametime = 1000.0 / 120.0; //1000.0 / 120.0; m_repaintTimer->start(targetFrametime); }
Everytime when gui gets updated i see a small stutter inside of my opengl window. QLineSeries updates seem to have a bigger effect, but even with a few QTableWidget changes i can see a small interupt in the rendering.
How do you normally update gui and opengl rendering at the same time?
Is there a way to the tell the gui it can render before or after opengl render frame is finished?
1/1