Microsoft DirectX 9.0

IDirect3DSurface9::GetContainer Method

Provides access to the parent cube texture or texture (mipmap) object, if this surface is a child level of a cube texture or a mipmap. This method can also provide access to the parent swap chain if the surface is a back-buffer child.


HRESULT GetContainer(      

    REFIID riid,     void **ppContainer );


[in] Reference identifier of the container being requested.
[out] Address of a pointer to fill with the container pointer if the query succeeds. See Remarks.

Return Value

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value can be D3DERR_INVALIDCALL.


If the surface is created using IDirect3DDevice9::CreateRenderTarget or IDirect3DDevice9::CreateOffscreenPlainSurface or IDirect3DDevice9::CreateDepthStencilSurface, the surface is considered stand alone. In this case, IDirect3DSurface9::GetContainer will return the Microsoft?Direct3D?device used to create the surface.

If the call succeeds, the reference count of the container is increased by one.

Here's an example getting the parent texture of a mip surface.

// Assumes pSurface is a valid IDirect3DSurface9 pointer
void *pContainer = NULL;
IDirect3DTexture9 *pTexture = NULL;
HRESULT hr = pSurface->GetContainer(IID_IDirect3DTexture9, &pContainer);
if (SUCCEEDED(hr) && pContainer)
	pTexture = (IDirect3DTexture9 *)pContainer;

© 2002 Microsoft Corporation. All rights reserved.