Sign in to follow this  
jujubean

OpenGL Writing to the Z-buffer.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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... =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this