Jump to content
  • Advertisement
Sign in to follow this  
jujubean

OpenGL Writing to the Z-buffer.

This topic is 5057 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!