Jump to content
• Advertisement

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

This topic is 2083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

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

#### Share this post

##### Share on other sites
Advertisement

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.

#### Share this post

##### Share on other sites

Thanks for the reply.

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

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
4. 4
Rutin
18
5. 5
• Advertisement

• 13
• 14
• 9
• 9
• 9
• ### Forum Statistics

• Total Topics
632926
• Total Posts
3009240
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!