[Kde-games-devel] QGraphicsScene performance

Ian Wadham ianw2 at optusnet.com.au
Fri Jun 29 08:39:51 CEST 2007


On Fri, 29 Jun 2007 02:02 pm, Matthew Woehlke wrote:
> Fela Winkelmolen wrote:
> > I just did a small test with a QGraphicsScene with a few balls bouncing
> > around, I noticed that with about 10 balls it starts becoming slow on my
> > system (using 100% of my cpu)
>
> Ten years ago we had games with multi-parallax
> backgrounds and dozens, if not hundreds, of sprites (ok, granted this
> was in 320x200 resolution)... and now ten wimpy sprites are bringing
> computers to their knees?
>
I don't think this is something in Fela's code.

Try the following experiment.  In your KDE4/Qt4 environment, run:

   $QTDIR/examples/graphicsview/portedcanvas/portedcanvas

This is one of the QGV examples.  Resize the window so that all
the static objects are in view.  In another window, start a "top"
command.  In the ported canvas window, hold down the Alt key
and type an "s" character 10 times.  That starts 10 QGV sprites.
Now I think you will see, in the "top" window, huge CPU usage
for processes "portedcanvas" and "X".

If you run "QT_FLUSH_PAINT=1 above_command" you will see
the sprites flicker yellow as they are updated.  In Qt 4.0, that
update would also cover other objects and large areas of
background between the sprites.  That was the "bounding
rectangle" problem.  Now, in Qt 4.3, that overhead seems to
have been replaced by another (less visible) one ... ;-)

All the best, Ian W.

PS. KGameCanvas *will* handle sprites efficiently.  One of my
KGoldrunner levels has 26 of them and the CPU usage is still low.


More information about the kde-games-devel mailing list