Performance Discrepancy Between QOpenGLWidget and freeGLUT in High-FPS Rendering
-
Hello,
I am working on a rendering application where I use both QOpenGLWidget (with Qt) and freeGLUT (in C++) to render images. However, I have noticed a significant performance difference between the two in terms of frames per second (FPS), and I am looking for advice on how to optimize the performance of QOpenGLWidget to match that of freeGLUT.
In my application, I render two 1920x1080 images using freeGLUT, and I am able to achieve around 5000 FPS. However, when rendering a single 1920x1080 image using QOpenGLWidget, the FPS drops significantly to around 1500 FPS. While I understand that Qt might introduce some overhead compared to freeGLUT, I am wondering if there are specific optimization techniques or settings within QOpenGLWidget that could help bring its performance closer to that of freeGLUT.
Here are a few details about my setup:
- Both environments are using OpenGL for rendering.
- I have disabled VSync in both contexts to maximize FPS.
- I am primarily using QOpenGLWidget for its integration with the rest of my Qt-based UI.
Is there any way to optimize QOpenGLWidget in a manner that can help me achieve FPS rates closer to those seen with freeGLUT? Any advice on improving rendering performance in QOpenGLWidget or minimizing Qt-related overhead would be greatly appreciated.
Thanks
// This is my QSurfaceFormat setting QSurfaceFormat fmt; fmt.setVersion(2, 0); // Set to the highest OpenGL version your system supports fmt.setRenderableType(QSurfaceFormat::OpenGL); fmt.setSwapBehavior(QSurfaceFormat::DoubleBuffer); fmt.setSwapInterval(QSurfaceFormat::DefaultSwapBehavior); // Disable VSync to get the highest FPS fmt.setProfile(QSurfaceFormat::CoreProfile); // Use the Core profile for modern OpenGL // ... // QMyOpenGLWidget is inherited from QOpenGLWidget void QMyOpenGLWidget::init() { m_qTimer = new QTimer(this); m_qTimer->setTimerType(Qt::PreciseTimer); connect(m_qTimer, SIGNAL(timeout()), this, SLOT(timeout())); m_qTimer->start(0); } // ... void QMyOpenGLWidget::timeout() { update(); } // ... void QWidgetPlay::paintGL() { if (m_bIsRendering) { return; } m_bIsRendering = true; QPainter p; p.begin(this); p.setRenderHints(QPainter::SmoothPixmapTransform); p.drawImage(QPoint(0, 0), m_imgTest1920_1080); p.end(); m_bIsRendering = false; }
-
Having no experience with OpenGL I would assume part of the „performance loss“ you see is caused by using the Qt signal slot mechanism. You could measure the delay between timeout calls but I guess this is one of the sources.
But I am asking myself two questions:- Do you really need to render with 1500 or 5000 fps? Noone going to see the differences.
- Why don‘t you use a separate render thread and update the UI at a lower rate with the result images?
-
I used X2L for game machine.
When I render a1920x1080 image with freeGLUT, I can get fps up to over 100.
But in case of QOpenGLWidget, I can't get even 20 fps.
So I decided to use X4, but I want to know the reason.
Thanks