How to properly trigger paintGL function ?
-
Hey
I'm trying to do some performance tests but I struggle with the way I need to trigger openGL to repaint.
Esentially if I use
Update()
float desiredFps = 1000.0f;
repaintTimer = new QTimer(this);
QObject::connect(repaintTimer, &QTimer::timeout, = { update(); });
repaintTimer->start(0); //time specified in ms
I'm limited to 60fps in my tests.If I use repaint
float desiredFps = 1000.0f;
repaintTimer = new QTimer(this);
QObject::connect(repaintTimer, &QTimer::timeout, = { repaint(); });
repaintTimer->start(0); //time specified in ms
60fps again.but if I use
float desiredFps = 1000.0f;
repaintTimer = new QTimer(this);
QObject::connect(repaintTimer, &QTimer::timeout, = { paintGL(); });
repaintTimer->start(0); //time specified in ms
I hit like 9000-10000+ fps(since its empty function) but as I also use aframes++; QPainter painter(this); painter.beginNativePainting(); glDisable(GL_DEPTH_TEST); painter.endNativePainting(); painter.setPen(Qt::red); painter.setFont(fpsFont); painter.drawText(10, 20, QString::number(cFps)); painter.end();
to draw the fps as a text, but that does not refresh properly with paintGL... so how am I to properly draw/update the widget?
TIA
-
Ok solved
It appears that a GLOBAL surface setInterval overrides the setIntervals I did on my glWidget. Kinda weird that the global one overrides local one if local one was specified, is this a bug ?
format.setSwapInterval(0); QSurfaceFormat::setDefaultFormat(format);
overrides on widget >
QSurfaceFormat format; format.setSwapInterval(0); setFormat(format);