raylopez99 wrote:
I just downloaded the apparently free SDK for DirectX 9, all 200+ MB
of it, but as I read about WPF I wonder: is DirectX obsolete? Should
I even bother learning how to use it? After all, the end user must
have the DirectX library installed on their PC before they can use any
video playing program you write.
DirectX 9 is included in Vista, and is so old that practially everybody
will have it installed on XP. Unfortunately, DirectX can be partially
installed and some systems don't have the managed bits.
Does WPF even use DirectX? Or are the functions of DirectX (mostly
video and graphics stuff, possibly accelerated via software or
hardware) already 'built into' WPF/Vista?
WPF uses Direct3D (the graphics bit of DirectX).
Managed DirectX is nice, but dead - Microsoft killed the development of
Managed DirectX 2 and encourages the use of XNA. I can't really comment
on XNA as I've not used it.
WPF gives you a nice abstraction over the Direct3D standard pipeline
(well... ish) with its 3D stuff. Performance is pretty good, and you can
write your own pixel shaders in .NET 3.5 SP1 (very recently released).
You can't write your own vertex shaders through. I also don't see a way
to manually manage which pool each texture are stored in.
In short, you can get better performance from Direct3D because you can
use vertex shaders and you can manually optimise what data needs to be
sent over the graphics bus (which can easily be the bottleneck in a 3D
application).
The disadvantages of Direct3D are *serious* though:
1) In Direct3D, you do a load of work and then call Device.Present(). If
you've done something wrong at any point, the only exception that is
ever thrown is DirectXExcption with a message: "Error in application",
and it will pretty much always be thrown when you call Present().
Debugging is a nightmare.
2) Direct3D is very low level. Drawing a triangle on the screen in a
robust way that won't crash when odd things happen takes hundreds of
lines of code.
3) You have to manually manage the differences between different
graphics cards (different features are avaliable on different graphics
cards).
4) Managed DirectX is no longer being actively developed (and I'm not
sure it's even supported).
Alun Harford