Sprite (quad) that uses 1 texture repeated multiple times

Started by
1 comment, last by AussieSpoon 11 years, 2 months ago

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

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.

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

This topic is closed to new replies.

Advertisement