![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Cutting Edge Direct 3D Programming
Direct3DRM: The Master InterfaceAs I mentioned earlier, Direct3D is a collection of COM interfaces. All the various interfaces that make up Direct3D depend on a single master object: Direct3DRM (RM stands for Retained-Mode). The Direct3DRM object represents Direct3D itself. The interface is created with the Direct3DRMCreate() function. For example: LPDIRECT3DRM d3drm; Direct3DRMCreate( &d3drm ); The LPDIRECT3DRM type is a pointer to a Direct3DRM interface. The Direct3DRMCreate() function creates the object and initializes the interface pointer. Once the Direct3DRMCreate() function returns successfully (well talk about return codes later in this chapter), the Direct3DRM interface is ready to use. Creating Direct3D ObjectsThe primary purpose of the Direct3DRM interface is the creation of other Direct3D objects. Most of the Direct3DRM member functions have Create prefixes. The object creation member functions are:
It is certainly not necessary to use all of these functions. Some are virtually identical to each other. For example, the only difference between the CreateLight() and CreateLightRGB() member functions is how the color of the light source is specified. Because the Direct3DRM interface is needed in order to create other Direct3D objects, Direct3DRM is usually the first object that a program creates. Modifying The Search PathAnother role of the Direct3DRM interface is to allow you to modify the search path that Direct3D uses to look for files. The path can be examined and modified with these member functions:
By default, Direct3D installs c:\dxsdk\sdk\media as the search path. You can override or append this path using the search path member functions, but the changes that your program makes will take effect only during the course of your programs execution. This path will not be installed on an end users machine, so your programs should not rely on its existence.
Controlling The Update PaceFinally, the Direct3DRM object defines a Tick() member function. Tick() controls the rate at which a program runs. Each time the Tick() function is called, Direct3D updates animated elements in a scene and renders the results. Calling Tick() often updates the scene often; calling Tick() infrequently slows the program. In addition, the Tick() member function takes a single parameter that controls the animation rate within a scene. For most situations, using a value of 1.0 is desirable, but a programs pace can be fine-tuned at runtime by using different values. Direct3DRMDevice: The Device InterfaceDirect3D devices are objects that create rendered output. Direct3D supports a number of device types. Programs can either choose a device from a list of available devices, or instruct Direct3D to select a device automatically. The two main types of devices are software devices and hardware devices. Software devices allow programs to run on computers that are not equipped with 3D accelerated video hardware. Hardware devices are available only on computers with 3D hardware and allow Direct3D to make full use of the features that are present on the hardware. A device is represented with the Direct3DRMDevice interface and can be created using the Direct3DRM member functions. There are three ways to create a device:
Once a device has been created it is used to specify rendering settings and perform the rendering of scenes. Color ModelsBoth software and hardware devices come in two varieties: RGB and Ramp. The RGB color model supports colored lighting, while the Ramp color model does not. Reduced overhead allows Ramp devices to out-perform RGB devices. Ramp devices are also called mono devices because of their monochromatic treatment of light sources. This can be misleading, however, since only the light sources are monochromatic in Ramp mode. Meshes and faces enjoy full color capability in Ramp mode.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |