Skip to main content
GameDev.net gamedev.net
🔒 Locked

triangles and textures (2D)

Started by germangb Aug 17, 2012 at 11:59 PM 1 replies 1.5k views
Original Post
germangb
germangb
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:

k2exV.png

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

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

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

Any reply is appreciated,
many thanks.
Goran Milovanovic
Goran Milovanovic
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 | +-------------------------------------
germangb
germangb
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.