By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,709 Members | 1,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,709 IT Pros & Developers. It's quick & easy.

c# and GDI graphics

P: n/a
Hi

I had an app i write on DirectX that will nearly always run in a windowed
situation. It could also have many instances running at a time and as such
to keep the cpu usage down i had a frame refresh sticker ever 32 ms rather
than maximum speed. This worked great but then i thought as all my graphics
are 2D this is huge over kill.

So i decided to port it to GDI graphics. At first a good idea i could easily
do everything i was using with Directx but less end requirements for the
user and much smaller code and less 'set up' code.

However first i found severe flicker with the GDI solution. So i implemented
a double buffer which solved the flicker but all my transparent imagery was
lost (due to the doubling up). I found if i clear the back buffer to prevent
doubling up i get a flicker again.

this all aside a even bigger problem, my cpu usage is FAR worse than it was
with directx. With a refresh every second it still spikes to 18% for one
instance. I have seen rival products on the market use simple graphics who
keep the cpu under 5% when i had 10 instances open.

What am i doing wrong? Is it possible to make an efficient GDI app?

Sep 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Daniel,

It is possible, but the one main advantage that the DirectX solution has
over the GDI app is that DirectX is going to utilize hardware acceleration
when it can, whereas GDI won't (you are simply pushing pixels to the screen
there, very low level).

If your requirements and your development permit (XP/2003 and above,
don't mind using the .NET 3.0 framework which is not even in beta yet), you
might want to try using the Windows Presentation Foundation. It will give
you the benefits of hardware acceleration (it utilizes DX underneath the
covers) and an easy programming model.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Daniel" <Da*****@vestryonline.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hi

I had an app i write on DirectX that will nearly always run in a windowed
situation. It could also have many instances running at a time and as such
to keep the cpu usage down i had a frame refresh sticker ever 32 ms rather
than maximum speed. This worked great but then i thought as all my
graphics are 2D this is huge over kill.

So i decided to port it to GDI graphics. At first a good idea i could
easily do everything i was using with Directx but less end requirements
for the user and much smaller code and less 'set up' code.

However first i found severe flicker with the GDI solution. So i
implemented a double buffer which solved the flicker but all my
transparent imagery was lost (due to the doubling up). I found if i clear
the back buffer to prevent doubling up i get a flicker again.

this all aside a even bigger problem, my cpu usage is FAR worse than it
was with directx. With a refresh every second it still spikes to 18% for
one instance. I have seen rival products on the market use simple graphics
who keep the cpu under 5% when i had 10 instances open.

What am i doing wrong? Is it possible to make an efficient GDI app?

Sep 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.