Sign in to follow this  
kgstation

Question about 2D UI in 3D scene(Direct3D9)

Recommended Posts

I'm currently using ID3DXSprite interface to draw an 2D UI,like an inventory,role states etc...
But if I draw those 2D UI, my 3d scene render would be ended...
So how can I draw 2D UIs in 3D scene properly?

Share this post


Link to post
Share on other sites
All that ID3DXSprite does is provide a wrapper around standard vertex buffers, index buffers and draw calls so this is a problem that you're going to need to resolve anyway. The general way to handle 2D UI is to switch to an ortho projection, load identity onto view and world, disable depth test and depth write, possibly enable alpha blending, then just draw stuff. There are a coupla other alternatives, one of which would involve using an XYZRHW FVF (this avoiding the need to switch to ortho/etc), but that's really all there is to it.

Share this post


Link to post
Share on other sites
[quote name='mhagain' timestamp='1343120654' post='4962543']
All that ID3DXSprite does is provide a wrapper around standard vertex buffers, index buffers and draw calls so this is a problem that you're going to need to resolve anyway. The general way to handle 2D UI is to switch to an ortho projection, load identity onto view and world, disable depth test and depth write, possibly enable alpha blending, then just draw stuff. There are a coupla other alternatives, one of which would involve using an XYZRHW FVF (this avoiding the need to switch to ortho/etc), but that's really all there is to it.
[/quote][quote name='mhagain' timestamp='1343120654' post='4962543']
All that ID3DXSprite does is provide a wrapper around standard vertex buffers, index buffers and draw calls so this is a problem that you're going to need to resolve anyway. The general way to handle 2D UI is to switch to an ortho projection, load identity onto view and world, disable depth test and depth write, possibly enable alpha blending, then just draw stuff. There are a coupla other alternatives, one of which would involve using an XYZRHW FVF (this avoiding the need to switch to ortho/etc), but that's really all there is to it.
[/quote]
Thanks...It's working!The problem is that I released deptbuffer when I render sprite!It's fine now!

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