Sign in to follow this  
AussieSpoon

Sprite (quad) that uses 1 texture repeated multiple times

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 

 

5uql9g.jpg

 

 

 

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


Link to post
Share on other sites

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


Link to 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:

 

343nsz8.png

 

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

 

 

29dhiis.jpg

 

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


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