•      Sign In
• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

# triangles and textures (2D)

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.

2 replies to this topic

### #1germangb  Members   -  Reputation: 211

Like
0Likes
Like

Posted 17 August 2012 - 05:59 PM

Hello, I've been hanging around these forums for like a month or so, sience I started with the game programming stuff, but anyways...

I have the 2d map made of triangles:

and the following texture (this is just an example, so the size of the image is not a power of 2):

My question is: is there any opengl method to make the map look like this directly:

or I have to specify the texture coordinates "manually"?

Any reply is appreciated,
many thanks.

Sponsor:

### #2Goran Milovanovic  Members   -  Reputation: 1104

Like
1Likes
Like

Posted 17 August 2012 - 11:49 PM

Texture coordinates range from 0 to 1, on both the x and y. So, you just have to project your geometry verts into that space, and that should give you the appropriate texture coordinates.

You can write a program to do it, or you can use a tool like Blender, which comes with many "UV Unwrap" functions.

+---------------------------------------------------------------------+

| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+

### #3germangb  Members   -  Reputation: 211

Like
0Likes
Like

Posted 18 August 2012 - 07:35 AM

hello @Goran Milovanovic, thank you very much for the reply!!
I've just realized how easy it is to implement by just dividing the vertex coordinates by the size of the texture.

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