2d drawing perfomance issue

Advanced game related topics
User avatar
Controller
User
User
Posts: 28
Joined: Thu Jul 22, 2004 5:26 am
Location: Germany
Contact:

2d drawing perfomance issue

Post 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
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: 2d drawing perfomance issue

Post 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.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
Controller
User
User
Posts: 28
Joined: Thu Jul 22, 2004 5:26 am
Location: Germany
Contact:

Re: 2d drawing perfomance issue

Post by Controller »

Thanks, helped me out alot. Got most of the stuff working so far, and it's really fast now.
Post Reply