Directx copying the depth buffer

This is a discussion on Directx copying the depth buffer within the Game Programming forums, part of the General Programming Boards category; In the middle of my render code I needed to clear the zbuffer draw some objects (for a mirror) and ...

  1. #1
    Registered User
    Join Date
    Aug 2004
    Posts
    731

    Directx copying the depth buffer

    In the middle of my render code I needed to clear the zbuffer draw some objects (for a mirror) and than I need to resume back to the state of the zbuffer before I cleared. However as far as I can tell directx offers no support in doing that so does anyone have any ideas?

  2. #2
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    This is because you should not mess with the Z buffer. The Clear() function in IDirect3DDevice9 will allow you to clear the Z buffer.

  3. #3
    Registered User
    Join Date
    Aug 2004
    Posts
    731
    Ya I guess directx doesn't let you touch the depth buffer at all. But I have found a way around it kinda. I just created a seperate depth buffer for the mirror and switched the depth buffers up during the rendering of the mirror stuff. However this requires rendering the relfected objects 3 times:

    1) Real positions (visible)
    2) Draw real positions to the mirror's depth buffer (not visible)
    3) Draw reflected position using the mirror's depth buffer (visible)


    The mirror works perfect and looks great but it can pretty slow if I am drawing alot. If anyone knows how to do a mirror a better way than please give some input.
    Last edited by Rune Hunter; 04-29-2007 at 09:50 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 02:27 AM
  2. Reading a buffer line by line, while using system read
    By Hammad Saleem in forum C Programming
    Replies: 9
    Last Post: 05-27-2008, 05:41 AM
  3. Having Buffer Problems With Overlapped I/O --
    By Sargera in forum C++ Programming
    Replies: 0
    Last Post: 02-07-2006, 03:46 PM
  4. DirectSound - multiple sounds
    By Magos in forum Game Programming
    Replies: 9
    Last Post: 03-03-2004, 03:33 PM
  5. getline problem
    By Unregistered in forum C++ Programming
    Replies: 4
    Last Post: 10-06-2001, 09:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21