Jump to content

  • Log In with Google      Sign In   
  • Create Account

14 years ago on June 15th Gamedev.net was first launched! We want to thank all of you for being part of our community and hope the best years are ahead of us. Happy birthday Gamedev.net!

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: 156

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: 882

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.
Learn the basics with my Python 3 video tutorial series. Looking for a good game engine, and relevant tutorials? Here you go.
Small and simple Python 3.x media library: pslab

#3 germangb   Members   -  Reputation: 156

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