OpenGL and frame drop
-
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.
-
I have on my laptop (Lenovo X200 - Intel X4500 HD) 30FPS instead of 60. I can get 60 FPS with
@format.setSwapInterval(0);
@ -
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();
}
@ -