Sign in to follow this  
lordimmortal2

Drawing Overlapped Sprites

Recommended Posts

I'm currently working with DirectX 9 (specifically the 2D portion of it) and would like to draw sprites in front of each other in a particular order.
I have tried drawing sprites from bottom to top and also using the Z coordinate of the draw function, but still nothing.

I'm probably missing something simple, but anyway you can do it with DX9 would be appreciated. Thanks for reading and any replies.

Share this post


Link to post
Share on other sites
[quote name='lordimmortal2' timestamp='1347394328' post='4979036']
but still nothing
[/quote]
Please elaborate on what "nothing" means: none of the sprites show up, or their order is incorrect?

Can you get a single sprite to show up?

Share this post


Link to post
Share on other sites
If you disable reading/checking the depth buffer, and draw your sprites far-to-near, you're doing what you intend to. I would also like to know what you mean by "nothing"

And, not to nitpick, but there really is no "2D portion of DX9". It typically depends on the projection matrix how things are displayed, though. I understand what you're saying...

Share this post


Link to post
Share on other sites
[quote name='yewbie' timestamp='1347469552' post='4979367']
Which functions are you using to draw?
DrawPrimitive ?

Are you using any Dx9 wrappers or just raw directx?
[/quote]

There's always something I'm not clear enough on. This is specifically just a 2D game, and I'm using the sprite method of DirectX along with the draw function. I'm not drawing with textured quads.

As for if I'm using any DX9 wrappers or just raw DirectX, if I understand you correctly it's the latter. I've created everything besides the calls to the DX and Windows APIs.

[quote]Please elaborate on what "nothing" means: none of the sprites show up, or their order is incorrect?
Can you get a single sprite to show up?[/quote]

I'm sorry that was really horribly worded. To elaborate - I can get things to draw, and sometimes they draw in the correct order but other times they don't. Right now, just for test purposes I have a background sprite draw behind all the GUI elements I need to draw for the main menu, but when I try to draw my options menu within the actual game, it gets drawn behind everything else. I'm drawing everything in the order of bottom to top, from the main menu to the game.

Specifically what I'm looking for is just a simplistic list of what you're supposed to do to get this to work, ideally with the z-coordinate.

[quote]If you disable reading/checking the depth buffer, and draw your sprites far-to-near, you're doing what you intend to. I would also like to know what you mean by "nothing"
And, not to nitpick, but there really is no "2D portion of DX9". It typically depends on the projection matrix how things are displayed, though. I understand what you're saying...[/quote]

Again, really horribly worded. I'm not using textured quads to render any of this stuff, just draw calls to a "LPD3DXSPRITE". And by "nothing" I meant "it's not doing what I want it to do, IE drawing things behind something I don't want it to." I need to work on my choice of words.

Share this post


Link to post
Share on other sites
Without seeing any code I would guess that maybe your Z might be getting casted to a whole number or something.

If you could provide your drawing function I am sure I could help.

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