When I use a render target higher in resolution than 512×512, I receive an image with black borders, depending on how big this texture was.
Why is this? How can I fix it?
Here's how I create the texture and render target surface:
p_Device->CreateTexture(512, 512, 1, D3DUSAGE_RENDERTARGET,
D3DFMT_A16B16G16R16, D3DPOOL_DEFAULT, &p_renderTexture, NULL);
p_mainRenderTexture->GetSurfaceLevel(0, &p_renderSurface);
And this is the main render-to-texture function:
void RenderSceneToTex(LPDIRECT3DDEVICE9 p_Device, D3DCOLOR clearColor,
LPDIRECT3DSURFACE9 p_renderSurface, D3DXMATRIX matView,
D3DXMATRIX matProjection, bool drawWater, bool drawTransparent,
bool drawSkybox, LPSTR renderTech) {
p_Device->SetTransform(D3DTS_VIEW, &matView);
p_Device->SetTransform(D3DTS_VIEW, &matProjection);
effect->SetMatrix("matView", &matView);
effect->SetMatrix("matProjection", &matProjection);
p_Device->SetRenderTarget(0, p_renderSurface);
p_Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
((clearColor != NULL)?clearColor:D3DCOLOR_XRGB(0, 0, 0)), 1.0f, 0);
p_Device->BeginScene();
DrawSceneObjects(p_Device, drawWater, drawTransparent,
drawSkybox, renderTech);
p_Device->EndScene();
p_Device->SetRenderTarget(0, p_dx_mainRenderSurface);
}