Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------
- // Creating texture for rendering video
- //------------------------------------------------
- // ID3D11Device* Device
- ID3D11Texture2D* texture = nullptr;
- D3D11_TEXTURE2D_DESC td;
- RtlZeroMemory(&td, sizeof(D3D11_TEXTURE2D_DESC));
- td.Width = textureWidth;
- td.Height = textureHeight;
- td.MipLevels = 1;
- td.ArraySize = 1;
- td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
- td.SampleDesc.Count = 1;
- td.Usage = D3D11_USAGE_DYNAMIC;
- td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
- td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
- hr = Device->CreateTexture2D(&td, nullptr, &texture);
- //------------------------------------------------
- // Updating texture
- //------------------------------------------------
- // ID3D11DeviceContext* DeviceContext
- D3D11_MAPPED_SUBRESOURCE resource;
- UINT subresource = D3D11CalcSubresource(0, 0, 0);
- HRESULT hr = DeviceContext->Map(texture, subresource, D3D11_MAP_WRITE_DISCARD, 0, &resource);
- // update using data pointer
- BYTE* ptr = reinterpret_cast<BYTE*>(resource.pData);
- DeviceContext->Unmap(texture, subresource);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement