Next, we analyze various technologies that can be used to render three-dimensional text in the photo editor application. We evaluate the strength and limitations of each technology before we decide on how to implement this requirement.
9.2.1 GDI+ and DirectX
Taking a closer look at GDI+, we realize that our requirements for three-dimensional text cannot be fulfilled using the graphics functionality provided by the .NET class library. All classes in GDI+ are restricted to two dimensions. This does not really surprise us because Microsoft offers a powerful 3D graphics library called DirectX (formerly Direct3D). Unfortunately, this library is targeted toward professional game developers. In addition to being dependent on the installation of a fairly large DirectX SDK package for development, it is rather difficult to learn and would not quite fit within the context of this book.
An easier-to-learn alternative to DirectX is OpenGL. It is also a powerful graphics library, providingas DirectX doesaccess to the rendering capabilities of the video card installed in the user's computer. Because the OpenGL operations are performed by the video card itself and not in software, programs using OpenGL are also referred to as hardware accelerated. A true acceleration, of course, can be observed only if the algorithm is complex enough, and that is usually the case for rendering three-dimensional scenes. So it is arguable whether a two-dimensional photo-editing program should rely on special hardware to do certain operations or whether it would be better to implement them in software.
9.2.3 Software versus Hardware Rendering
Compared with the latest 3D games, rendering a line of text might seem to be a fairly simple task that could be implemented entirely in software without introducing any hardware dependencies. Unfortunately it is not simple. To achieve nice-looking results, you must be familiar with lighting models, shading, perspective projections, and so on. Even for a highly skilled person, implementing a software rendering algorithm from scratch is a time-consuming task. This is especially significant when we know that we can achieve a similar result with only a few lines of code using a 3D graphics library.
The easiest and fastest method to implement the 3D text feature appears to be OpenGL. Also, in recent years almost every PC sold comes with an OpenGL-compatible graphics card. As a result, we will not introduce any dependency on "special" hardware as long as we use no chip-dependent extensions. We add a constraint to the list of requirements stating the OpenGL graphics card dependency of the 3D text feature, as shown in Table 9.2.
Rendering three-dimensional text requires a graphics card compatible with OpenGL 1.2. No vendor-specific extension may be used.
Introducing Software Engineering
A .NET Prototype
The Photo Editor Application
GDI+ Graphics Extensions
Advanced GDI+ Operations
Dynamic Loading of Components
Accessing System Resources
Performance Optimization, Multithreading, and Profiling
Building the Web Application with ASP.NET
Security and Database Access