Z-Buffer use
EACamJust a quick question. What's a Z-Buffer for? I think I have an idea, but I'm making a 2D game. Does a Z-Buffer have any application in a 2D game? If so, how, and how can I utilize it? Thanks.
Sr. GuapoA z-buffer basically stores depth information for each pixel. That way, the order that you draw things does not affect the order they are "layered". Without a depth buffer, the last thing you drew would be the furthest up (it would overlap everything). With a depth buffer, it would depend on the various depths of the objects as to which was on top. The nice thing about depth buffer is they are VERY easy to use. Just use these three lines: D3DWindow.EnableAutoDepthStencil = 1 D3DWindow.AutoDepthStencilFormat = D3DFMT_D16 D3DDevice.SetRenderState D3DRS_ZENABLE, 1 after initialising the device, and voila, the graphics card does the rest. I am pretty sure they can be used in 2D (though I am not 100%). It would make sense that they could, or the z-value on vertices would be pointless. It would definately make rendering much easier... [;)]
game_makeras Sr. Guapo said you can use z values to layer your sprites instead of a loop,,, thats means you can draw sprite A before Sprite B and keeping Sprite A above B using z sorting values [:)] I remeber once I was stack in a problem : How Can you control the apearance of a sprite behind or above 3D Objects ,,, I changed the z value to 1 [:)]
EACamCool...I'll try to use it in my 2D game and see what happens. But, doesn't a stencil buffer limit my audience? I mean, i've heard that not ALL adapters have the capabilities. So would using it be a limiting factor in my game? P.S. I currently have only the ZENABLE line in my init, but not the first 2, and I clear the Z-Buffer every frame, but I don't actually use it, as far as i know.
VBBRWell I think you CAN use a Z-Buffer while NOT needing to use a stencil buffer. Better to do some research on this. (I don't know clearly what a stencil buffer is, anyway [:P])
Sr. GuapoYes, I always use a Z-Buffer, but I have never used a stencil buffer. I think I know what they could be used for, but I've never needed one...
Almar JolingI've never used a Z-buffer. I might use one in my next game I guess. This is the first time I actually read it's 100% possible in DG... :)
VBBRWhat is "DG"? Sorry for my dumbness...
Sr. GuapoI was kinda wondering that also... [:D]. Is it direct Graphics maybe? Z-Buffers are very helpful. They are extremely easy to use and almost EVERY card can support them (including my ancient Voodoo3). They make rendering much easier by letting you draw ojects in any order, though they still are correct (You should still group objects though, less "SetRenderState" or SetTexture" calls = faster loop).
VBBRJust imagine 3D graphics without Z-Buffers! Cheers to the guy who created them!
Almar JolingDirectGraphics yes, just like D3D is Direct3D, D3DIM = direct 3d Immediate mode, D3DRM = Direct 3d retained mode
VBBRSee, I'm not really into this immediate mode and retained mode stuff, I'm from the DirectX8-DirectX9 era [:D]
Sr. GuapoSame here... As far as I know, RM is easier, but not high quality, and IM is harder, but can look much better and support more features. I don't think I want to know anymore though, it almost seems like a step back...