Followed this guide here
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".
I have the sprite and background displaying but have no idea how to get the data.
I also tried doing this:
//Create device D3D11_TEXTURE2D_DESC desc; ZeroMemory(&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->CreateTexture2D(&desc, nullptr, &texture); m_d3dDevice->CreateShaderResourceView(texture, 0, &textureView); // Render D3D11_MAPPED_SUBRESOURCE mapped; m_d3dContext->Map(texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped); data = (BYTE*)mapped.pData; rows = (BYTE)sizeof(data); std::cout << "hi" << std::endl; m_d3dContext->Unmap(texture, 0); 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?
Edit: currently I found
D3D11_SHADER_RESOURCE_VIEW_DESC desc; m_background->GetDesc(&desc); desc.Buffer; // buffer