title: DirectX 11 changing the pixel bytes
body: <p>Followed this guide <a href="https://github.com/Microsoft/DirectXTK/wiki/Sprites-and-textures" rel="nofollow">here</a></p>
  
  <p>I am tasked with "using map and unmap methods to draw a line across the screen by setting pixel byte data to rgb red values".</p>
  
  <p>I have the sprite and background displaying but have no idea how to get the data.</p>
  
  <p>I also tried doing this:</p>
  
  <pre><code>//Create device
  D3D11_TEXTURE2D_DESC desc;
  ZeroMemory(&amp;desc, sizeof(D3D11_TEXTURE2D_DESC));
  desc.Width = 500;
  desc.Height = 300;
  desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
  desc.Usage = D3D11_USAGE_DYNAMIC;
  desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
  desc.MiscFlags = 0;
  desc.MipLevels = 1;
  desc.ArraySize = 1;
  desc.SampleDesc.Count = 1;
  desc.SampleDesc.Quality = 0;
  desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
  
  
  m_d3dDevice-&gt;CreateTexture2D(&amp;desc, nullptr, &amp;texture);
  m_d3dDevice-&gt;CreateShaderResourceView(texture, 0, &amp;textureView);
  
  // Render
  D3D11_MAPPED_SUBRESOURCE mapped;
  m_d3dContext-&gt;Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &amp;mapped);
  
  data = (BYTE*)mapped.pData;
  rows = (BYTE)sizeof(data);
  
  std::cout &lt;&lt; "hi" &lt;&lt; std::endl;
  m_d3dContext-&gt;Unmap(texture, 0);
  </code></pre>
  
  <p>Problem is that in that case data array is size 0 but has a pointer. This means that I am pointing to a texture that doesn't have any data or am I not getting this?</p>
  
  <p>Edit:
  currently I found </p>
  
  <pre><code>D3D11_SHADER_RESOURCE_VIEW_DESC desc;
  m_background-&gt;GetDesc(&amp;desc);
  desc.Buffer; // buffer
  </code></pre>