I often get asked why Microsoft created Windows Presentation Foundation (WPF). “What’s wrong with Windows Forms? Why not just extend the forms engine ” is a another common question.
To answer that question you first need to look at the graphic rendering engines that Microsoft produces.
GDI has been around for a long time. It’s original intent was to abstract the drawing of graphics from the hardware devices (monitors, printers). GDI lacks 3D rasterization and has no support for animation.
GDI was replaced with GDI+ when Windows XP was released. GDI+ has some improvements over GDI in the 2D rendering engine.
- Support for JPG and PNG images
- Add Alpha channel (transparent) to color via ARGB
- Floating point values for coordinates
- Better graphics path tools
- Gradient shading
GDI+ did not add support for animation or 3D rasterization.
DirectX first appeared in 1995. It was created to lure game developers away from writing games for DOS and to start creating computer games for Windows.
DirectX has seen a constant stream of enhancement during the last thirteen years. It supports full color graphics, animation, video, multi-part audio and 3D. Here is a partial list of of the DirectX components:
Direct3D: Graphics accelerated rendering of 3D objects. All modern graphics cards supports Direct3D acceleration.
DirectSound: Enable low latency playing of sounds.
DirctMusic: Enable playing music and sound effect in games.
DirectShow: High quality capture and playback of streaming media and multimedia streams.
Which rendering engine for WPF?
The WPF architects were given the responsibility for designing a new managed .NET framework for rendering complex UI. They had to choose a rendering engine for WPF. Which to choose? GDI+? DirectX? Create a new rendering engine?
DirectX offers more features than GDI/GDI+ and is enhanced every year. Since GDI+ looks like a dead end the choice was obvious, pick DirectX.
This means that WPF has a more robust rendering engine and can render more complex UI than if Microsoft had chosen to continue to develop on the old GDI engine.