View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# Sprite (quad) that uses 1 texture repeated multiple times

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1AussieSpoon  Members

Posted 31 January 2013 - 08:33 PM

Hello,

I have a program that creates a sprites using quads in a vertex buffer.

I'm wondering if it is possible to instead of creating multiple quads side by side it is possible to make them 1 quad the re-uses the texture drawn and repeat it multiple times?

e.g. Using the image below I'm trying to achieve b) using the Sprite, instead of  doing a), which uses 4 quads instead of 1

How would I achieve this?

If this is hard to explain without my Texture/sprite code, I can post it if it makes it easier.

Thanks

### #2Jason Z  Members

Posted 31 January 2013 - 09:36 PM

You just need to create a single quad in the shape of B), but using the wrap texture addressing mode and set the texture coordinates on the right hand vertices to (4,0) and (4,1) respectively.

Jason Zink :: DirectX MVP

Direct3D 11 engine on CodePlex: Hieroglyph 3

Games: Lunar Rift

### #3AussieSpoon  Members

Posted 01 February 2013 - 09:29 AM

Is it possible to do this with specific co-ordinates of a texture? (repeat only 1 specific part of it)

I am using this image:

I am trying to repeat only the pink square and cross part, but when I render I get:

The way I am doing it is by generating the uv co-ordinates as normal and then multiplying appropriate vertices u/v by the number of repeats I want (additional sprites)

//Set Vertex 1 (Bottom Left)
​                        //Other code omitted
pVertex[VertexCounter].u1 = pTexture->GetTextureUMin();
pVertex[VertexCounter].v1 = pTexture->GetTextureVMax();
VertexCounter++;
//Set vertex 2 (Top Left)
pVertex[VertexCounter].u1 = pTexture->GetTextureUMin();
pVertex[VertexCounter].v1 = pTexture->GetTextureVMin() * pSprite->m_TimesRepeatedY;
VertexCounter++;
//Set vertex 3 (Top Right)
pVertex[VertexCounter].u1 = pTexture->GetTextureUMax() * pSprite->m_TimesRepeatedX;
pVertex[VertexCounter].v1 = pTexture->GetTextureVMin() * pSprite->m_TimesRepeatedY;
VertexCounter++;
//Set vertex 4 (Bottom Right)
pVertex[VertexCounter].u1 = pTexture->GetTextureUMax() * pSprite->m_TimesRepeatedX;
pVertex[VertexCounter].v1 = pTexture->GetTextureVMax();
VertexCounter++;

Is there any obvious problem with this? Or something else?

Thanks

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.