# OpenGL How to align textures properly?

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

## Recommended Posts

I'm currently working on a 2d OpenGL game.. I'm looking for advices on how to set up the textures on my polygons so they look to be all fitting together? For example, take a look at this screenshot from "Soldat": http://www.soldat.pl/pl/screens/screenshot5.jpg The grass texture fits everywhere, there's no "cut" in the texture between the triangles.. How would I be able to do that? Also, most of the polygons in liero are huge, and they contains concave segments.. How is it possible to have a concave polygon? If you know any good guide/tutorial which could help me, I'd be glad to know it. Thanks a lot.

##### Share on other sites
The easiest way is to find or create textures that fit well naturally. By that I mean squares that, when tiled, show no strange cuts.
You can also blend multiple textures in various stages, and there are many more options.

A polygon can be concave if it contains more than three sides. Polygons don't always have only three sides, although its common practice (video cards are optimized to handle triangles, the are al lot of mathematical issues, etc.)

##### Share on other sites
I think I'll go with a combinaison of triangles instead of complex polygons..
Anyway, I think an image would represents well what I think could work:

The big square on the top left would be the main texture I want to apply on my polygons, in a sort of repeated way.
So you can see on the 3 triangles exactly how should the texture be applied.

The problem is that I really have no idea how to do that.

##### Share on other sites

As you probably know, a vertex has (if you're using textures, that is) U and V coordinates for the texture mapping, ranging from 0 to 1 (represented on the left side of the picture). Point P is an example.

Using one of the polygons as an example, you can see where it fits right over the original square. Now you can simply calculate (or in my case, guess ;)), what the values for the U and V will be.

##### Share on other sites
That led me in the right direction, everything works fine now!
It wasn't that hard after all, thanks a lot ;)

1. 1
Rutin
29
2. 2
3. 3
4. 4
5. 5

• 13
• 13
• 11
• 10
• 13
• ### Forum Statistics

• Total Topics
632960
• Total Posts
3009474
• ### Who's Online (See full list)

There are no registered users currently online

×