What am I doing wrong?
I want to create multisampled render target with bitmap from image.
My plan is:
render target
and offscreen-plain
surfacesoffscreen
surface with bitmapStretchRect
to copy data from offscreen-plain
to render target
IDirect3DSurface9* targetSurface;
IDirect3DSurface9* sourceSurface;
device->CreateRenderTarget(width, height, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_4_SAMPLES, 0, false, &targetSurface, NULL);
device->CreateOffscreenPlainSurface(width, height, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &sourceSurface, NULL);
D3DLOCKED_RECT lockedRect;
sourceSurface->LockRect(&lockedRect, NULL, 0);
// Writing data...
sourceSurface->UnlockRect();
// Copy image content to render target
device->StretchRect(sourceSurface, NULL, targetSurface, NULL, D3DTEXF_POINT);
But the rendered result is not what I expect.
The problem was the wrong bitmap filling.
RenderTarget size is power of two.
Also, offscreen-plain is redundant, so the code is following:
IDirect3DSurface9* surface;
device->CreateRenderTarget(width, height, D3DFMT_A8R8G8B8, D3DMULTISAMPLE_4_SAMPLES, 0, true, &surface, NULL);
D3DLOCKED_RECT lockedRect;
surface->LockRect(&lockedRect, NULL, 0);
// Writing data...
surface->UnlockRect();