O'Reilly logo

WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 23. Three-Dimensional Drawing

WPF relies on Microsoft's DirectX technologies for high-quality multimedia support. The DirectX libraries include methods to display images, present video, and play audio files that take advantage of the computer's hardware to provide the best performance and highest quality possible.

One of my favorite parts of DirectX is Direct3D, the three-dimensional (3D) drawing library. Direct3D lets a program display complex animated 3D scenes with multiple light sources, smooth color shading, and realistic textures — all in real time.

The TexturedBlock example program shown in Figure 23-1 displays a simple cube with sides made of various materials sitting on a brick and grass surface. You can use the sliders to rotate the scene in real time.

Figure 23-1

Figure 23.1. Figure 23-1

Unfortunately, writing Direct3D code to display these types of objects is fairly involved. One of the first and most annoying tasks is figuring out what graphics hardware is available on the user's computer. Determining which device objects you need to get the most out of the user's computer can be confusing.

Fortunately, WPF's 3D drawing objects handle this setup for you. Although they don't always give you quite the same performance you could achieve using Direct3D yourself, it's a lot easier to get a program up and running in WPF.

That doesn't mean that the rest of the process is easy. Producing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required