Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
Supported Effect Parameters Unfortunately, some members of the TDIEffect structure may be unsupported by some drivers. For example, a specific driver may not allow an effect to be associated with a trigger, or it may not support repeated playback of triggered effects. However, the application can use the GetEffectInfo method of the IDirectInputDevice2 interface to determine which TDIEffect parameters are supported. The GetEffectInfo method is defined as:
    function GetEffectInfo(

    var pdei: TDIEffectInfoA;    // effect information structure

    const rguid: TGUID           // effect GUID

    ) : HResult;                 // returns a DirectX error code
The rguid parameter should be set to the GUID of the effect for which information is requested (these GUIDs are listed below when we get to creating the effect). The pdei parameter should be set to a variable of type TDIEffectInfoA. When this method returns, the TDIEffectInfoA structure will be initialized with all of the relevant information concerning the specified effect. The TDIEffectInfoA structure is defined as:
    TDIEffectInfoA = packed record

      dwSize : DWORD;                          // size of the structure in bytes

      guid : TGUID;                            // the effect GUID

      dwEffType : DWORD;                       // effect type flags

      dwStaticParams : DWORD;                  // supported parameter flags

      dwDynamicParams : DWORD;                 // dynamically modifiable parameters

      tszName : array [0..MAX_PATH-1] of CHAR; // effect name

    end;
The dwStaticParams member contains a series of flags that indicate which members of the TDIEffect structure are supported. These flags are listed in Table 8-1. If you combine each flag with the dwStaticParams member using a Boolean AND operation, you can easily determine which TDIEffect members are supported by the driver. However, it is not always necessary to determine if a specific member is supported or not. If a member of this structure is not supported, it will simply be ignored by the driver. Therefore, you could go ahead and assign values to specific members and never worry about getting an error when you create the effect. On the other hand, you’ll probably need to know if an effect can be assigned to a trigger button and if this effect can be repeated if that is integral to game play, and find an appropriate alternative if this functionality is not supported.
Table 8-1: Supported TDIEffect member flags
Flag | Supported TDIEffect Member
--- | ---
DIEP_DURATION DIEP_SAMPLEPERIOD DIEP_GAIN DIEP_TRIGGERBUTTON DIEP_TRIGGERREPEATINTERVAL DIEP_AXES DIEP_DIRECTION DIEP_ENVELOPE | dwDuration dwSamplePeriod dwGain dwTriggerButton dwTriggerRepeatInterval cAxes, rgdwAxes rglDirection lpEnvelope
The dwSize member, of course, must be set to SizeOf(TDIEffectInfoA) before calling the GetEffectInfo method. The guid member contains the GUID of the effect, and the tszName member contains the name of the effect type. The dwEffType member will contain a series of DIEFT_* flags indicating the effect type. You may want to check this member, as if it contains the DIEFT_DEADBAND, DIEFT_FFATTACH, DIEFT_FFFADE, DIEFT_ POSNEGCOEFFICIENTS, DIEFT_POSNEGSATURATION, or DIEFT_ SATURATION flags, the effect supports the lDeadBand parameter (covered below under condition effects), the attack and fade envelope parameters, positive and negative coefficient values (covered below under condition effects), positive and negative saturation values (also covered below under conditions), and saturation of condition effects, respectively. Incidentally, dwDynamicParams also contains a series of DIEP_* flags that indicate which members of the TDIEffect structure can be changed dynamically while the effect is playing. This allows an application to modify an effect on the fly to reflect changes in the game world or to create more complex effects. We’ll look at an example of modifying an effect on the fly later in this chapter. The following listing demonstrates how the GetEffectInfo method can be used to determine which members of the TDIEffect structure are supported.
Previous | Table of Contents | Next

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. Read EarthWeb's privacy statement.