Drawing Overlapped Sprites

Started by
5 comments, last by yewbie 11 years, 7 months ago
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.
Prove me wrong so I can know what's right.
Advertisement
Which functions are you using to draw?
DrawPrimitive ?

Are you using any Dx9 wrappers or just raw directx?

but still nothing

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?

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

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...

Which functions are you using to draw?
DrawPrimitive ?

Are you using any Dx9 wrappers or just raw directx?


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.

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.

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.
Prove me wrong so I can know what's right.
Can you post the code that draws your sprite collection? It sounds like something else is going on aside from a simple back-to-front draw order. I'm curious what else happens during the render loop.

Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)

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.

This topic is closed to new replies.

Advertisement