Page 1 of 1

2d drawing perfomance issue

Posted: Wed Dec 02, 2015 8:26 pm
by Controller
so far, i did lot's of optimations on my project, and seems to have an speed issue when output all that rendered stuff. Environment:
* Regular Window which may change size, standard windows gdi drawing
* after inital clearing (fillrect), 5000 rectangulars are drawn (createsolidbrush, fillrect, deleteobject(brush))
* content is copyied to the real window output dc (bitblt)
However this is damn small, So I want to use hardware acceleration. Big problem is I don't have much experience how this will improve performance.
Also I don't know if I should use regular 2d drawing (e.g. box()) or sprites instead.

Can anyone share some experience?
Thanks in advance

Re: 2d drawing perfomance issue

Posted: Thu Dec 03, 2015 3:50 am
by Lunasole
GDI is very slow comparing to directx/opengl.
You should use OpenWindowedScreen with FlipBuffers (), there are some examples within help file > Screen.

Then draw sprites (it is the fastest way), or use StartDrawing(ScreenOutput()) to draw on screen like you drawing on window (this is slower, but should be much faster than window drawing anyway), or even use direct access to screen buffer (see DirectScreenDrawing.pb example), it might be even fastest than drawing prepared sprites.

Also there is Canvas gadget for windowed mode, but didn't tried it and not sure how it works.

PS. In my project I'm drawing 3148 objects using OpenWindowedScreen() with only 10% CPU usage and 7% GPU usage (and GPU keeps sleeping mode) / without FPS drop, that includes scaling, physics simulation and more other manipulations executed 60 times per second with every object. PB is nicely optimized and uses drawing libraries directly, I guess it's speed is close to C / C++ so just try more optimal way.

Re: 2d drawing perfomance issue

Posted: Thu Dec 03, 2015 10:29 pm
by Controller
Thanks, helped me out alot. Got most of the stuff working so far, and it's really fast now.