DrawPrimitiveMotivation As we have seen in the sample application, managing data in immediate mode is not an easy task. Keeping track of the data using offsets into an array is very difficult. Additionally, changes occuring in the data storage can be very disastrous on the code which accesses this data. To ease the situation, the concept of DrawPrimitive was introduced in Direct3D, in ver 5.0 of DirectX. An interesting point about ver 5.0 is that it is MMX enabled. Goals The goals of DrawPrimitive are:
Introduction DrawPrimitive is still for immediate mode programming. The features it provides are very similar to those provided by execute buffers. DrawPrimitive provides a cleaner syntax than that provided by execute buffers. The DrawPrimitive concept does not provide wrappers for execute buffers. DrawPrimitve completely sidesteps execute buffers, without sacrificing performance. DrawPrimitive provides its own path to the rendering facilities of the hardware, different that the path provided by execute buffers. It still provides direct access to the 3D accelerate hardware and provides emunaltion if the hardware does not support a certain feature. Drawing Primitives DrawPrimitive provides support for drawing primitves, like points, lines and triangles. The application can also pass its own data structures to DrawPrimitive. Data using DrawPrimitve is rendered on a DirectDrawSurface object, using the DrawPrimitve or DrawIndexedPrimitive functions. The data to be rendered can be drawing primitives directly or an array of vertices with the rendering information. DrawPrimitive Sample After giving an introduction to DrawPrimitive, let us consider a small piece of code, to illustrate the concept and its ease of use over the execute buffers. The sample source is shown in figure 21.
For the DrawPrimitve Specification and White Paper, refer [4] and [5]. For a tutorial, refer [6]. For details about 3D graphics, the rendering pipeline and various algorithms, refer [7], [16], [17], [14], [15] and [8].
|
|||||||||||