views:

259

answers:

1

Hi!

I'm new to opengl-es on android and struggling to get my head around the concept of texturing.

I am looking to produce a tilemap of various difference textures. I understand that it is better to use an atlas of all the combined textures so I don't repeatedly rebind. However I am unsure quite how to then map these textures on to my tilemap.

I understand the process of specifiying vertices and then coordinates of where on the texture map I wish to take them from (i drew a picture too!)

Click for image - curse newbies not allowed to post images :(

But my question is can I draw a triangle strip that is, in effect, longer than one "tile" but map a different area of the texture to that "tile".

So instead of drawing a triangle strip pretending to be a quad, one at a time for each tile, can I somehow draw a whole row of the tilemap (like 1,2,3,4 and cleverly shift around the texture coordinates so each "tile" is now from a different area of the texture? So for example I draw a triangle strip 4 tiles long but shift the texture coordinates so the first "tile" is the yellow of my texture the second red ... third blue... etc

If I've not explained myself too well apologies!

It might just be that this is not possible and I have to draw each one individually which seems like I've saved effort with an atlas, then had to draw them all out slowly anyway regardless. Hmm.

A: 

Sure, just adjust texture coordinates, that is how texture atlases work.

Matias Valdenegro
Even if I say draw a strip of say 10 vertices making 4 tiles where obviously tiles that touch share vertices? Can you use multiple texture coordinates for the same vertex? Either way I will give what I want to do a try and hopefully it will work, if not I'll be back!
iexus
No, but you can duplicate vertices and use degenerate triangles so you don't have to restart the strip.
Matias Valdenegro
Thanks for the advice! I was confused by what you meant to begin with. I've been away for a few days and literally just came back, sat down and *click* I think understood what you meant. Time to get coding!
iexus

related questions