Writing to the Z-buffer.
Is it possible to write a "pre" defined array of values to the Z-buffer in DirectX? I know it can be done in opengl using:
glDrawPixels(width, height, GL_DEPTH_COMPONENT, GL_FLOAT, myPtrToASavedZBufferAsFloats);
Is there a directX equivelent?
If your depth format is D16_LOCKABLE, then I suppose you could lock and write a predefined images. Other than that, no, I don't think you can... but I'm not certain.
My guess would be to use IDirect3DDevice9::GetDepthStencilSurface() to get a pointer to the depth/stencil surface. Then, you could use D3DXLoadSurfaceFromMemory() to copy data straight from memory to the depth/stencil surface. Then just release the surface and go back to rendering. Just a guess, though; I can't guarantee that it'd work. And if you wanted to write only the depth stuff, and preserve the stencil stuff (assuming you even have stencil stuff), then you'd probably have to call IDirect3DSurface9::LockRect() and copy the data over manually.
[edit]If the default depth/stencil surface isn't lockable, you might be able to manually create one, and set up your own swap chain. As above, though, I don't really know if it'd work or not.[/edit]
[edit]If the default depth/stencil surface isn't lockable, you might be able to manually create one, and set up your own swap chain. As above, though, I don't really know if it'd work or not.[/edit]
Quote:Original post by Agony
My guess would be to use IDirect3DDevice9::GetDepthStencilSurface() to get a pointer to the depth/stencil surface. Then, you could use D3DXLoadSurfaceFromMemory() to copy data straight from memory to the depth/stencil surface. Then just release the surface and go back to rendering.
Keep in mind that'd still require a lockable depth buffer.
Quote:Keep in mind that'd still require a lockable depth buffer.
couldnt you set the depth stencil as a render target and write to it through the render pipeline?
something like,
D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET
sounds a bit farfetched... =)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement