first of all: when using Qt, please prefer using its methods above using platform dependent stuff.
#include <QtGui/QApplication>
#include <QDebug>
#include "balltest.h"
#include <QTime>
int main(int argc, char *argv[])
{
Balltest w;
w.setGeometry( 200, 200, 1024, 768 );
w.show();
while( w.IsRunning() )
{
if( (prevTime.
msecsTo(QTime::currentTime())) >
= 0.025 ) {
w.Update();
prevTime
= QTime::currentTime();
}
a.processEvents();
}
return 0;
}
#include <QtGui/QApplication>
#include <QDebug>
#include "balltest.h"
#include <QTime>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Balltest w;
w.setGeometry( 200, 200, 1024, 768 );
w.show();
QTime prevTime = QTime::currentTime();
while( w.IsRunning() )
{
if( (prevTime.msecsTo(QTime::currentTime())) >= 0.025 )
{
w.Update();
prevTime = QTime::currentTime();
}
a.processEvents();
}
return 0;
}
To copy to clipboard, switch view to plain text mode
works on any platform (even though I'd recommend to use a QTimer firing regularly !)
Looked on your code and tried on X11, the "problem" is simply due to the fact that the screen updates are based upon rectangular areas which are repainted one after each other, so depending on the platform / gfx card / driver / processor you'll get more or less tear and flicker.
With OpenGL you'll at least circumvent this partially, because GL renders into an offscreen buffer which is switched after all paint operations are done.
You will still have tearing, which occurs due to the fact that you're changing the screen contents just while it's being displayed, but you can get rid of this when waiting for VBlank (can be adjusted in most graphic card drivers).
Bookmarks