Results 1 to 19 of 19

Thread: What is the fastest way to draw a circle ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What is the fastest way to draw a circle ?

    Well... you can't draw in the middle of a pixel. If you scale up the painter, the precision should increase.

  2. #2
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What is the fastest way to draw a circle ?

    Quote Originally Posted by wysota View Post
    Well... you can't draw in the middle of a pixel. If you scale up the painter, the precision should increase.
    I could suppose that QT can resample my pixmap using algorithm similar to one using for resizing...

    Anyway, for now I've decided to use OpenGL which should be available in 90% cases with fallback to slow software rendering in other cases. On old machines without OpenGL even QPixmap approach can be too slow so I'll probably provide advances options to draw particles as points instead of circles.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What is the fastest way to draw a circle ?

    Here is something to play with. Some parts of the code are commented and uncommenting some of them might change the behavior a bit.

    The most important part is the one that makes sure the animation is "lag-undependent" - items will move properly regardless of the number of frames the hardware can handle.
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: What is the fastest way to draw a circle ?

    Quote Originally Posted by wysota View Post
    Here is something to play with. Some parts of the code are commented and uncommenting some of them might change the behavior a bit.

    The most important part is the one that makes sure the animation is "lag-undependent" - items will move properly regardless of the number of frames the hardware can handle.
    Thanks ! GL version gives 25fps for me. In my case position calculation is more complicated: each frame is calculated in separate thread and calculation sometimes can be long. However frame time is adjustable so I'll try to follow your ideas and adjust it when rendering takes more time than calculations.

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.