Original Post
I'm using DirectX 9 and I try to resize the back and depthbuffer so I can change the window size (where d3d renders to) and avoid my screen getting pixelated (anyone knows a better term for that?). From here (Resizing the window) I got an explanation how to do this, without calling device->reset. This is the code I could come up with (code found here): I'm calling this function right after I create the device. I don't get any error (using the debug runtimes), but some warnings (like "Direct3D9: (WARN) :Ignoring redundant SetSamplerState Sampler: 0, State: 21" or "Direct3D9: (WARN) :Ignoring redundant SetRenderState - 22"), but they also appear when I do NOT call this function, so my guess is that they're unrelated and I can take care of those warnings after resizing does work. The thing is, if I call CreateSwapChain(), the CStatic control (that's the control I want my scene to be rendered in) stays black. It doesn't if I don't call CreateSwapChain(): The Scene is rendered as it should. Can anybody tell me what could possibly go wrong here?
void CD3D::CreateSwapChain()
{
D3DPRESENT_PARAMETERS scparam;
memset(&scparam, 0, sizeof(scparam));
scparam.Windowed = true;
scparam.hDeviceWindow = m_WindowHandle; // This is the same handle I used in createdevice
scparam.BackBufferCount = 1;
scparam.BackBufferFormat = m_d3ddm.Format; // <= is queried before and set to D3DFMT_X8R8G8B8
scparam.BackBufferHeight = m_iScreenheight;
scparam.BackBufferWidth = m_iScreenwidth;
scparam.SwapEffect = D3DSWAPEFFECT_COPY;
scparam.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
// Create a swapchain
V( m_pd3dDevice->CreateAdditionalSwapChain( &scparam, &m_pSwap ) );
// Get the backbuffer from the swapchain
V( m_pSwap->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &m_pSwapRenderSurf ) );
// Create a depth buffer
V( m_pd3dDevice->CreateDepthStencilSurface( m_iScreenwidth, m_iScreenheight, D3DFMT_D24S8, D3DMULTISAMPLE_NONE, 0, false, &m_pSwapDepthSurf, 0) );
// Get the backbuffer and depth buffer from the device and store them away for reset/resize usage
V( m_pd3dDevice->GetBackBuffer( 0, 0, D3DBACKBUFFER_TYPE_MONO, &m_pDevRenderSurf ) );
V( m_pd3dDevice->GetDepthStencilSurface( &m_pDevDepthSurf ) );
// Set the device's rendertarget to the backbuffer from the swap chain, and set the depth buffer to the one you've created
V( m_pd3dDevice->SetRenderTarget( 0, m_pSwapRenderSurf ) );
V( m_pd3dDevice->SetDepthStencilSurface( m_pSwapDepthSurf ) );
D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 0;
vp.Width = m_iScreenwidth;
vp.Height = m_iScreenheight;
vp.MinZ = 0;
vp.MaxZ = 1;
V( m_pd3dDevice->SetViewport(&vp) );
}