Jump to content

  • Log In with Google      Sign In   
  • Create Account


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.

  • You cannot reply to this topic
2 replies to this topic

#1 AussieSpoon   Members   -  Reputation: 184

Like
0Likes
Like

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 

 

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



Sponsor:

#2 Jason Z   Crossbones+   -  Reputation: 4846

Like
3Likes
Like

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.



#3 AussieSpoon   Members   -  Reputation: 184

Like
0Likes
Like

Posted 01 February 2013 - 09:29 AM

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






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.



PARTNERS