ID3D11Texture2D* pTexture = nullptr; pDevice->CreateTexture2D(&desc, &initData, &pTexture);
HRESULT hr = DirectX::LoadFromWICFile( L"example.png", DirectX::WIC_FLAGS_NONE, &metadata, image ); nd3d11 texture create from file
DirectX::CreateShaderResourceView( pDevice, scratchImage.GetImages(), scratchImage.GetImageCount(), metadata, &pSRV ); ID3D11Texture2D* pTexture = nullptr
if (FAILED(hr)) return hr;
if (SUCCEEDED(hr)) std::cout << "Texture created successfully!" << std::endl; else std::cerr << "Texture creation failed!" << std::endl; HRESULT hr = DirectX::LoadFromWICFile( L"example.png"
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;
std::wcerr << L"Failed to load image: " << std::hex << hr << std::endl; return 1;