Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The simplest way to create a texture is to describe its properties and call the texture creation API. This topic shows how to create a texture.
To create a texture
- Fill in a D3D11_TEXTURE2D_DESC structure with a description of the texture parameters.
- Create the texture by calling ID3D11Device::CreateTexture2D with the texture description.
This example creates a 256 x 256 texture, with dynamic usage, for use as a shader resource with cpu write access.
D3D11_TEXTURE2D_DESC desc;
desc.Width = 256;
desc.Height = 256;
desc.MipLevels = desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.Usage = D3D11_USAGE_DYNAMIC;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.MiscFlags = 0;
ID3D11Device *pd3dDevice; // Don't forget to initialize this
ID3D11Texture2D *pTexture = NULL;
pd3dDevice->CreateTexture2D( &desc, NULL, &pTexture );
Related topics