Nd3d11 Texture Create From File __link__ [ OFFICIAL ]

UINT width, height; pFrame->GetSize(&width, &height); UINT stride = width * 4; UINT imageSize = stride * height; BYTE* imageData = new BYTE[imageSize]; pConverter->CopyPixels(nullptr, stride, imageSize, imageData); D3D11_TEXTURE2D_DESC desc = {}; desc.Width = width; desc.Height = height; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; desc.SampleDesc.Count = 1; desc.Usage = D3D11_USAGE_DEFAULT; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.CPUAccessFlags = 0; D3D11_SUBRESOURCE_DATA initData = {}; initData.pSysMem = imageData; initData.SysMemPitch = stride;

if (SUCCEEDED(hr) && pSRV)

hr = DirectX::CreateShaderResourceView( pDevice, scratchImage.GetImages(), scratchImage.GetImageCount(), metadata, ppSRV ); nd3d11 texture create from file

// Create D3D11 device ComPtr<ID3D11Device> pDevice; D3D11CreateDevice( nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, 0, nullptr, 0, D3D11_SDK_VERSION, &pDevice, nullptr, nullptr ); UINT stride = width * 4

int main()

// Load the image from disk using WIC DirectX::TexMetadata metadata; DirectX::ScratchImage scratchImage; HRESULT hr = DirectX::LoadFromWICFile( filename, DirectX::WIC_FLAGS_NONE, &metadata, scratchImage ); UINT imageSize = stride * height

// Cleanup delete[] imageData; pConverter->Release(); pFrame->Release(); pDecoder->Release(); DDS files support block compression (BC1-7), mipmaps, and cubemaps.