Windows with C++: Introducing Direct2D

I’ve been away from my computer for a few days working on a house renovation project and didn’t notice that my latest Windows with C++ column came out until the mail man delivered a copy of the June 2009 issue of MSDN Magazine.

In this issue I introduce a new technology that I’m very excited about. I’ve been waiting for Direct2D for some time. When Microsoft started pushing WPF as the “one true path” (TM) I just couldn’t persuade myself to buy the sales pitch. If you felt the same way then read on. This just might make your day.

Windows with C++: Introducing Direct2D

With the introduction of Windows Vista a few years ago, it was clear that the era of the Windows Graphics Device Interface (GDI) was coming to an end. GDI, even with the help of GDI+, had been showing its age especially when compared to the superior graphics capabilities of Windows Presentation Foundation (WPF). As if that weren't enough, GDI lost its hardware acceleration while WPF took advantage of Direct3D's abundance of hardware acceleration.

However, if you want to develop high-performance and high-quality commercial applications, you'll still look to C++ and native code to deliver that power. That's why few things excite me more about Windows 7 than the introduction of Direct2D and DirectWrite. Direct2D is a brand new 2D graphics API designed to support the most demanding and visually rich desktop applications with the best possible performance. DirectWrite is also a brand-new API that complements Direct2D and provides hardware-accelerated text, when used with Direct2D, and high-quality text layout and rendering with advanced support for OpenType typography and ClearType text rendering.

In this article, I will explore these new technologies and give you an idea of why it matters and how you can start using them today.

Big thanks to Mark Lawrence and Ben Constable, from the Direct2D team, for their feedback on the article as well as for providing a side bar discussing rendering performance.

Stay tuned for more Direct2D articles in my upcoming Windows with C++ columns.

If you’re looking for one of my previous articles here is a complete list of them for you to browse through.

Produce the highest quality screenshots with the least amount of effort! Use Window Clippings.

7 Comments

  • Wow, thank you. I'm a Win32/C++ hobbiest and this is very exciting info!

  • Backport it to XP, pretty please.

  • Nice article. You make no metion of the other DirectX 2-D API, the now-dead DirectDraw. Any tips for those of us stuck with maintaining/porting DirectDraw-based applications?

  • Looks very promising for porting some old DirectDraw code which mainlying did bitblts. Like Anon asked, any tips in that area? Also, will Direct2D be supported on Vista?

  • SSchulz: Direct2D will be available on Windows Vista. I’m afraid I don’t have any experience with DirectDraw.


  • Hi. Forgive my ignorance but I am a
    Mfc C++ developer and was making the
    Move over to C#/.net with wpf, mainly
    Because of the richness it allows and
    The performance promise of ease of
    Access to gpus. However it is proving
    Slower than expected and we cannot fully
    Understand why. There seems to be little
    Written on high-perf graphics and how
    Wpf fairs to the other options. So
    I am keen to understand what is behind
    Your articles gambit comment that native
    Code and C++ are still needed for perf.
    Are you saying that to truly get performance
    We should be writing directly and natively
    With directx? And if so are there other
    Ways to get access to directx in a managed
    Environment other than through wpf? And
    Where is the performance cost from using
    Wpf that you imply?

    If there articles I could read I would appreciate
    The redirect.

    Thanks!

  • Aidan: Managed code promises higher productivity compared to C++ which for the most part is true. In theory it can also match the performance of native code but in practice this is rarely achieved in desktop applications.

    The issues with WPF and Direct2D however are not about managed vs. native. It’s about immediate-mode graphics vs. retained-mode graphics. Immediate-mode will almost always be faster in practice regardless of whether it’s native or managed. WPF just happens to be a retained-mode graphics API and thus it will be slower by design.

    So WPF is simpler but Direct2D is faster. If you want to get the performance of Direct2D/Direct3D with managed code you’ll have to use the managed Direct3D wrapper libraries. Of course that will be more complex than Direct2D even though you’re using managed code since Direct2D is much simpler than Direct3D.

Comments have been disabled for this content.