Platform SDK: DirectX

Accessing Cubic Environment Map Faces

[C++]

Like any other complex surface, you navigate between faces of a cubic environment map by using the IDirectDrawSurface7::GetAttachedSurface method. The GetAttachedSurface method accepts a pointer to a DDSCAPS2 structure that describes the attached surface the method should retrieve. Set the dwCaps2 member to any of the flag values beginning with "DDSCAPS2_CUBEMAP_", combined with the DDSCAPS2_CUBEMAP flag, to retrieve the corresponding face.

The following code retrieves the cube-map surface used for the positive-y face (face 2).

// For this example, the pddsMainFace variable contains a valid
// pointer to the face returned by CreateSurface when the cube map
// was originally created.
LPDIRECTDRAWSURFACE7 pddsFace2;

DDSCAPS2 ddsCaps;
ddsCaps.dwCaps2 = DDSCAPS2_CUBEMAP_POSITIVEY | DDSCAPS2_CUBEMAP;

HRESULT hr;
hr = pddsMainFace->GetAttachedSurface( &ddsCaps,
                                       &pddsFace2);

if( FAILED(hr) )
{
    // code to handle error goes here.
}
[Visual Basic]

Like any other complex surface, you navigate between faces of a cubic environment map by using the DirectDrawSurface7.GetAttachedSurface method. The GetAttachedSurface method accepts a DDSCAPS2 type that describes the attached surface the method should retrieve. Set the lCaps2 member to any of the flag values from the CONST_DDSURFACECAPS2FLAGS enumeration that begin with "DDSCAPS2_CUBEMAP_", combined with the DDSCAPS2_CUBEMAP flag, to retrieve the corresponding face.

The following code retrieves the cube-map surface used for the positive-y face (face 2).

' For this example, the ddsMainFace variable contains a valid
' reference to the face returned by CreateSurface when the cube map
' was originally created.
Dim ddsFace2 As DirectDrawSurface7
Dim ddsCaps As DDSCAPS2

ddsCaps.lCaps2 = DDSCAPS2_CUBEMAP_POSITIVEY Or DDSCAPS2_CUBEMAP

Set ddsFace2 = ddsMainFace.GetAttachedSurface(ddsCaps)

If Err.Number <> DD_OK Then
    ' code to handle error goes here.
End If