Using DirectX 9 with .NET

  • Thread starter Thread starter Paul Wardle
  • Start date Start date
P

Paul Wardle

Don't know whether to post this to a DirectX newsgroup, but I'd post it here
:)

I have written a C# MDI app utilising GDI+ to do the drawing. Performance is
terrible. (I have double buffering, but this causes other problems,
especially at high zoom levels - on large documents).

Is it possible to use DirectX9 to paint MDI child windows? I have seen some
samples, and they seem to use a busy loop to continually redraw a window,
calling Application.DoEvents after each iteration.

Why do they need to do this? Would it work to have multiple MDI childs and
update those in the loop? Why not just respond to paint events instead of
replacing the message loop?

Maybe I just don't get it.... :)

Anyone have any ideas? Any advice? Anyone actually done this with any
success?

Thanks -

Paul Wardle
 
I recently published an article in Well Formed that showed how to use
DirectX to speed up Windows Forms drawing.

I think its a viable solution but it is a litle quirky. I also think that
the code generated by the DirectX app-wizard that comes with the 9.x SDK is
over complex but it's easy to get away with that using boilerplate code.

http://www.bobpowell.net/october2003.htm

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com
 
Is it possible to use DirectX9 to paint MDI child windows? I have seen
some
samples, and they seem to use a busy loop to continually redraw a window,
calling Application.DoEvents after each iteration.

Why do they need to do this? Would it work to have multiple MDI childs and
update those in the loop? Why not just respond to paint events instead of
replacing the message loop?

Anyone have any ideas? Any advice? Anyone actually done this with any
success?

I have an assembly currently available intended for use with the DX9 Summer
Update that supports multiple control views, its currently in an alpha state
(until I get my C#-2003 at Christmas!) available in preview form at
www.btinternet.com/~nfactorial/downloads/Framework3D.zip (for those
interested).

For non-realtime apps it is easier (and much less strain on the machine) to
respond to the applications Idle event, couple this with a 'dirty' flag for
each viewport and rendering only when the flag is set allows an alternative
that reduces the burden to almost non-existant.

n!
 
Hi Paul!

In case your do not code MDI game environment (hehe) the simplest solution
is to create single device in MDI Parent for drowing all MDI Children and
not using game loop but as indicated by n! just responding to Paint events -
works smoothly with app processor load unnoticeably low - afterall your
graphics card does the job! If you need some animations use technique from
internet technology - timers for managing animation time scale i.e.
unmanaged TIME class - rather than resources exhousting game loop.

hope this helps

Jacek
 
Thanks guys

Bob - I seem no to able to access the page you suggested - do I need a
subscription...?
n! - not been able to get your stuff to work yet - do you have an executable
that I can run to have a peek?
Jacek - thanks for the advice!

I get my PC back from the repair man tomorrow, so I should be able to have a
hard play over Xmas..the wife'll love me for it :)

I'll let you know how I get on.

Thanks again.

Paul
 
Back
Top