将数据从 Offscreen-plain 复制到渲染目标
Copy data from Offscreen-plain to Render target
我做错了什么?
我想使用图像中的位图创建多重采样渲染目标。
我的计划是:
- 创建
render target
和 offscreen-plain
表面
- 用位图填充
offscreen
表面
- 使用
StretchRect
将数据从offscreen-plain
复制到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);
但是渲染出来的结果不是我想要的
问题是错误的位图填充。
RenderTarget 大小是二的幂。
此外,offscreen-plain是多余的,所以代码如下:
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();
我做错了什么?
我想使用图像中的位图创建多重采样渲染目标。
我的计划是:
- 创建
render target
和offscreen-plain
表面 - 用位图填充
offscreen
表面 - 使用
StretchRect
将数据从offscreen-plain
复制到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);
但是渲染出来的结果不是我想要的
问题是错误的位图填充。
RenderTarget 大小是二的幂。
此外,offscreen-plain是多余的,所以代码如下:
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();