Results 1 to 12 of 12

Thread: Rendering rectangles speed issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    229
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    2
    Thanked 29 Times in 28 Posts

    Default Re: Rendering rectangles speed issue

    Some years ago, during my studies, I took over a student project, written in C++/Qt-3.
    It was a simple user interface, whose main part was a simplified soccer field (a bitmap of about 500x300 pixels). Players were also drawn pixel-wise. Well, not pixel by pixel but in bitmap style, somehow.
    A robot soccer game was shown with 3 vs. 3 players.
    And the whole picture was flickering and awful slow. CPU utilisation was about 95% on an 1.5Ghz machine. Just für six players (shown as coloured circles) and on white filled circle as ball.

    I decided to rewrite some code.
    QCanvas of Qt3 was the "chosen one" for presenting/drawing the game.
    After I did this the CPU utilisation was ridiculous low. Everything went smooth. And it even looked better .

    Long story short:
    Use QGraphicsScene, which replaces the QCanvas from Qt3 in Qt4.
    Last edited by Boron; 11th March 2007 at 23:28.

  2. The following user says thank you to Boron for this useful post:

    macbeth (11th March 2007)

  3. #2
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default Re: Rendering rectangles speed issue

    Thanks for your answer!

    I'm just thinking about rewriting some code to see how would it behave with QGraphicsScene, it looks like it has many good features and supports printing and rendering to QPaintDevice, which is crucial for me...

  4. #3
    Join Date
    Jul 2006
    Location
    Poprad/Prague
    Posts
    33
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 2 Times in 2 Posts

    Default Re: Rendering rectangles speed issue

    Hm, another strange thing that showed up: when I add 250 000 small (5x5pix) rectangles on the GraphicsScene and then want to show it using GraphicsView, the cpu 'user' load rises to ~90%. Not just during plotting, but for all the time after the rectangles are drawn. That's looks quite strange to me... (If I draw ~50 000 rectangles, the cpu usage is about 50%)

    Does anybody know, what is GraphicsView doing in the background? Still updating the view?
    I'm quite disappointed, because they say in Qt docs:
    Graphics View uses a BSP (Binary Space Partitioning) tree to provide very fast item discovery, and as a result of this, it can visualize large scenes in real-time, even with millions of items.
    But how can one use it, if the cpu load is 90% :/

    Well, maybe I've made a mistake somewhere, but I just tried to edit one of the examples (portedcanvas in examples/graphicsview) and instead of adding one rectangle I added many of them, so I don't know what's wrong...

    Any advice appreciated, thanks...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.