Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectX 9 repeating sprites

Started by Such1 Jun 4, 2012 at 12:14 AM 5 replies 1.3k views
Original Post
Such1
Such1
Hey guys, I am working on my games GUI and I would like to know if there is a way to instead of resizing the texture, repeting it like we can do
in vertices drawing when we set the UV to more then 1.0f.

I know I can do a loop but I would like to know if there is an easier way.
My GUI will be generated from a texture that has the borders, corners and the middle of the window.

Or if you guys know a better way to do it I will be happy to listen it.
DJTN
DJTN
The only way I know of to get texture tiling with Sprites is to implement your own textured quad drawing, i.e. looping or resize (change) the texture.
Such1
Such1
Ok, thanks, I guess I'll have to avoid that technique to conserve time.
Such1
Such1
One more thing. Is there a way determine some kind of z-buffer to sprites?? To improve performance I would like to set the pixel only once, but I can't find a way to do it without ordering the DrawSprite calls.
I have a window with several controls.
How can I draw the controls before the window in a way that they keep over the window?
DJTN
DJTN
I'm not sure I understand your question. If you're refering to the Z-order, it is determined by the order the sprites are drawn.

Essentially, you should only have one ID3DXSprite in your entire application. Think of it as a sprite renderer, rather than an individual sprite.
Then you should only have a single Begin()..End() pair for all of your sprites. The order in which the drawing is done between the begin() and End() determines the z-order.
Such1
Such1
But is there a way to change that order??Or to do what I want I will have to cut the parts that should stay behind and are drawed after? Cause that's not very easy to do
DJTN
DJTN
Can you attach an image of the problem?

The z-order is determined by the order in which you render the sprites. The first one will be on the bottom and the next one would be on top of that, so on and so on. If you need the order to be dynamic you'll need to programically assign a draw order yourself with a list or some type of collection associated with your sprites. Normally you'd sort them so solid sprites are first and then transparent- layering them the way you want.

To recap:

Create a list of sprites.

Sort your objects from farthest to nearest.

Sort the objects from solid to transparent.

Render lists.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.