Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Performance Discrepancy Between QOpenGLWidget and freeGLUT in High-FPS Rendering
QtWS25 Last Chance

Performance Discrepancy Between QOpenGLWidget and freeGLUT in High-FPS Rendering

Scheduled Pinned Locked Moved Unsolved Game Development
4 Posts 2 Posters 485 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leom0311
    wrote on last edited by
    #1

    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;
    }
    
    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerReisende
      wrote on last edited by
      #2

      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:

      1. Do you really need to render with 1500 or 5000 fps? Noone going to see the differences.
      2. Why don‘t you use a separate render thread and update the UI at a lower rate with the result images?
      1 Reply Last reply
      0
      • L Offline
        L Offline
        leom0311
        wrote on last edited by
        #3

        Thanks for your answer.
        I don't want to rendering with high-fps like 1500~5000.
        I just want to know performance between QOpenGLWidget and freeGLUT.
        I mean why QOpenGLWidget is slower than freeGLUT.
        Thanks again.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          leom0311
          wrote on last edited by
          #4

          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

          https://radxa.com/products/x/x2l

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved