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. OpenGL and frame drop
Forum Updated to NodeBB v4.3 + New Features

OpenGL and frame drop

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 2.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    Sfiet_Konstantin
    wrote on last edited by
    #1

    Hi
    I'm currently working on an application that have to display pictures very quickly (1/60 s). I need to have 60 fps so I decided to use a QGLWidget and enabled VSync with

    @format.setSwapInterval(1);
    @

    But currently there are two strange problems.

    1. I have on my laptop (Lenovo X200 - Intel X4500 HD) 30FPS instead of 60. I can get 60 FPS with
      @format.setSwapInterval(0);
      @

    2. More important. I sometimes have "frame drop". When I need to display a picture for the 1/60s (ie on 1 frame), sometimes it is not displayed at all. Is there any way to force drawing it or at least detect this drop ?

    My testing code :

    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QGLWidget *widget = new QGLWidget(this);
    QGLFormat format = QGLFormat();
    format.setSwapInterval(0);
    widget->setFormat(format);
    
    ui->graphicsView->setViewport(widget);
    
    m_scene = new QGraphicsScene(this);
    m_scene->setBackgroundBrush(Qt::black);
    
    ui->graphicsView->setScene(m_scene);
    
    m_mainItem = m_scene->addRect(0, 0, 100, 100, QPen(), QBrush(Qt::blue));
    m_subItem = m_scene->addRect(0, 0, 100, 100, QPen(), QBrush(Qt::red));
    m_subItem->setVisible(false);
    
    QTimer *timer = new QTimer(this);
    timer->setInterval(0);
    timer->start();
    
    connect(timer, SIGNAL(timeout()), this, SLOT(slotTimeout()));
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::slotTimeout()
    {
    // Redraw
    m_counter ++;

    m_subItem->setVisible(m_counter % 60 == 0);
    ui->graphicsView->viewport()->update();
    

    }
    @

    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