It is currently Sat Jul 04, 2020 3:51 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: 2d drawing perfomance issue
PostPosted: Wed Dec 02, 2015 8:26 pm 
Offline
User
User
User avatar

Joined: Thu Jul 22, 2004 5:26 am
Posts: 25
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: 2d drawing perfomance issue
PostPosted: Thu Dec 03, 2015 3:50 am 
Offline
Addict
Addict
User avatar

Joined: Mon Oct 26, 2015 2:55 am
Posts: 923
Location: UA
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.

_________________
Kind of copyleft notify: all the source code created by me and posted on Purebasic official forums is free to use and modification in all possible (and several impossible) ways for anyone, without asking my permission


Top
 Profile  
Reply with quote  
 Post subject: Re: 2d drawing perfomance issue
PostPosted: Thu Dec 03, 2015 10:29 pm 
Offline
User
User
User avatar

Joined: Thu Jul 22, 2004 5:26 am
Posts: 25
Location: Germany
Thanks, helped me out alot. Got most of the stuff working so far, and it's really fast now.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye