Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to properly trigger paintGL function ?

How to properly trigger paintGL function ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qopenglwidgetqpaintqpainterqtimefps
2 Posts 1 Posters 913 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.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by
    #1

    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 a

    frames++;
    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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Dariusz
      wrote on last edited by
      #2

      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);
      
      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