SHARE
TWEET

Untitled

a guest Aug 24th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------------------------------
  2. // Creating texture for rendering video
  3. //------------------------------------------------
  4.  
  5. // ID3D11Device* Device
  6.  
  7. ID3D11Texture2D* texture = nullptr;
  8.  
  9. D3D11_TEXTURE2D_DESC td;
  10. RtlZeroMemory(&td, sizeof(D3D11_TEXTURE2D_DESC));
  11. td.Width = textureWidth;
  12. td.Height = textureHeight;
  13. td.MipLevels = 1;
  14. td.ArraySize = 1;
  15. td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
  16. td.SampleDesc.Count = 1;
  17. td.Usage = D3D11_USAGE_DYNAMIC;
  18. td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  19. td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  20.  
  21. hr = Device->CreateTexture2D(&td, nullptr, &texture);
  22.  
  23.  
  24.  
  25.  
  26. //------------------------------------------------
  27. // Updating texture
  28. //------------------------------------------------
  29.  
  30. // ID3D11DeviceContext* DeviceContext
  31.  
  32. D3D11_MAPPED_SUBRESOURCE resource;
  33. UINT subresource = D3D11CalcSubresource(0, 0, 0);
  34. HRESULT hr = DeviceContext->Map(texture, subresource, D3D11_MAP_WRITE_DISCARD, 0, &resource);
  35.  
  36. // update using data pointer
  37. BYTE* ptr = reinterpret_cast<BYTE*>(resource.pData);
  38.  
  39.  
  40. DeviceContext->Unmap(texture, subresource);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top