Jump to content

  • Log In with Google      Sign In   
  • Create Account


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.

  • You cannot reply to this topic
2 replies to this topic

#1 germangb   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:

Posted Image

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

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

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

Any reply is appreciated,
many thanks.

Sponsor:

#2 Goran Milovanovic   Members   -  Reputation: 1103

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.

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

| Need a programmer?        ->   http://www.nilunder.com/protoblend   |

| Want to become one?       ->   http://www.nilunder.com/tutoring     |
| Game Dev video tutorials  ->   http://www.youtube.com/goranmilovano |
+---------------------------------------------------------------------+

#3 germangb   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