ID3D11Texture2D* pTexture; // Create a 2D texture object D3D11_TEXTURE2D_DESC desc = {0}; // Set texture description parameters // ... HRESULT hr = pDevice->CreateTexture2D(&desc, NULL, &pTexture); // Release the texture object pTexture->Release(); pTexture = NULL;
ID3D11Texture2D* pTexture1; ID3D11Texture2D* pTexture2; // Create two 2D texture objects D3D11_TEXTURE2D_DESC desc = {0}; // Set texture description parameters // ... HRESULT hr1 = pDevice->CreateTexture2D(&desc, NULL, &pTexture1); HRESULT hr2 = pDevice->CreateTexture2D(&desc, NULL, &pTexture2); // Release one of the texture objects pTexture1->Release(); pTexture1 = NULL;This example shows how to create two 2D texture objects and then release one of them using the ID3D11Texture2D Release method. The method is called on the texture object that needs to be released, and then the object is set to NULL for safety. The ID3D11Texture2D Release method is part of the DirectX Graphics API, which is included in the DirectX SDK package library.