What I think is going on is the render target is successfully set but the texture applied to the render target is just showing up blue and not the mesh or any of the screen objects. A brief snipplet:
_declspec(dllexport) bool createRenderTarget() {
HRESULT result = S_OK;
D3D11_TEXTURE2D_DESC textureDesc;
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
D3D11_SHADER_RESOURCE_VIEW_DESC shaderResourceViewDesc;
///////////////////////// Map's Texture
// Initialize the texture description.
ZeroMemory(&textureDesc, sizeof(textureDesc));
// Setup the texture description.
// We will have our map be a square
// We will need to have this texture bound as a render target AND a shader resource
textureDesc.Width = m_TextureWidth; //-- Gloabl Texture Height and Texture Width varables.
textureDesc.Height = m_TextureHeight;
textureDesc.MipLevels = 1;
textureDesc.ArraySize = 1;
textureDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; //-- This is what the backbuffer is created when DirectX is initialized.
textureDesc.SampleDesc.Count = 1;
textureDesc.SampleDesc.Quality = 0;
textureDesc.Usage = D3D11_USAGE_DEFAULT;
textureDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
textureDesc.CPUAccessFlags = 0;
textureDesc.MiscFlags = 0;
// Create the texture
result = dev->CreateTexture2D(&textureDesc, NULL, &renderTargetTextureMap);
if (FAILED(result)) {
MessageBox(0, L"Unable to create render target texture!", L"Render Target failed!", 0);
return false;
}
/////////////////////// Map's Render Target
// Setup the description of the render target view.
ZeroMemory(&renderTargetViewDesc, sizeof(renderTargetViewDesc));
renderTargetViewDesc.Format = textureDesc.Format;
renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
renderTargetViewDesc.Texture2D.MipSlice = 0;
// Create the render target view.
result = dev->CreateRenderTargetView(renderTargetTextureMap, &renderTargetViewDesc, &renderTargetViewMap);
if (FAILED(result)) {
MessageBox(0, L"Unable to create render target.", L"Render Target failed!", 0);
return false;
}
// Setup the description of the shader resource view.
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
shaderResourceViewDesc.Format = textureDesc.Format;
shaderResourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
shaderResourceViewDesc.Texture2D.MipLevels = 1;
// Create the shader resource view.
result = dev->CreateShaderResourceView(renderTargetTextureMap, &shaderResourceViewDesc, &shaderResourceViewMap);
if (FAILED(result)) {
MessageBox(0, L"Unable to create Render Target.", L"Render Target Failed!", 0);
return false;
}
return true;
}
As for the quad rendering it uses the shaderResourceShaderMap. If I load a normal texture - it will be fine; however when I attempt to load what the render target has rendered out to the shaderResourceViewMap then it display blue quad. Inside the shader for the quad I just have it return the texture sample.
Perhaps inside the rendering loop of the quad I have to obtain the address for the shader resource view?