JavaScript EditorFree JavaScript Editor     Ajax Editor 



Main Page
  Previous Section Next Section

The New DirectX Color and Gamma Controls Interface

In DirectX 5.0, two new interfaces were added to help game programmers and video programmers gain more control over the color properties of the screen image without resorting to complex software algorithms. For example, it would seem to be a simple thing to add a little red to the image on the screen, change the tint, etc. But operations like these, which require nothing more than a turn of a knob on a television, are rather complex to perform with digital data in software. Thankfully, the two new interfaces IDirectDrawGammaControl and IDirectDrawColorControl let programmers make these changes with some very simple calls.

IDirectDrawColorControl is very similar to a TV interface and gives you control over the brightness, contrast, hue, saturation, sharpness, and general gamma. To use the interface, you must query for it from the primary surface pointer with the IID_IDirectDrawColorControl identifier. Once you have the interface, set up a DDCOLORCONTROL structure, shown here:

typedef struct _DDCOLORCONTROL
        {
        DWORD   dwSize;    // size of this struct
        DWORD   dwFlags;   // indicates which fields are valid
        LONG    lBrightness;
        LONG    lContrast;
        LONG    lHue;
        LONG    lSaturation;
        LONG    lSharpness;
        LONG    lGamma;
        LONG    lColorEnable;
        DWORD   dwReserved1;
        } DDCOLORCONTROL, FAR *LPDDCOLORCONTROL;

Next you make a call to IDIRECTDRAWCOLORCONTROL::SetColorControl(), and the primary surface will be immediately modified. The changes will remain in effect until you make another call.

HRESULT SetColorControl(LPDDCOLORCONTROL lpColorControl);

The gamma control is a little different. Instead of you setting all the TV-like settings, the gamma correction control gives you control over the red, green, and blue color ramps of the primary surface. In essence, the shape of the ramps you define determines the color response of red, green, and blue. The setup of an IDirectDrawGammaControl is similar to the color control, so I'm not going to cover it (as if I really covered the color control). Take a look at the DirectX SDK for more information on these subjects, because they can make a number of effects very easy to do, such as underwater scenes, screen flashes, lightness, darkness, and so on. The only problem is that they only work with hardware that supports them, and very few cards do—not one of mine does, so I can't make a demo!

      Previous Section Next Section
    



    JavaScript EditorAjax Editor     JavaScript Editor