Jump to content
  • Advertisement
Sign in to follow this  
suckxez

Texturing Iso Tiles

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm creating diamond shape tiles in OpenGL like this:
		glBegin(GL_TRIANGLE_STRIP );
			glTexCoord2f(0.0f, 0.0f); glVertex3f(float(m_PosX)		, float(m_PosY), 0.0f);
			glTexCoord2f(1.0f, 0.0f); glVertex3f(float(m_PosX + 1)	, float(m_PosY - 0.5f), 0.0f);
			glTexCoord2f(1.0f, 1.0f); glVertex3f(float(m_PosX + 1)	, float(m_PosY + 0.5f), 0.0f);
			glTexCoord2f(0.0f, 1.0f); glVertex3f(float(m_PosX + 2)	, float(m_PosY), 0.0f);
		glEnd();

But when I put a texture over a tile, the texture distorts. What I mean, I want to put textures like the following one over the tiles. But how do I do that?

Share this post


Link to post
Share on other sites
Advertisement
You could probably do it by tweaking your texture coordinates. Instead of mapping the entire image onto the diamond quad, you can selectively 'snip' out just the parts you want. Maybe something like:


glTexCoord2f(0.0f, 0.5f); glVertex3f(float(m_PosX), float(m_PosY), 0.0f);
glTexCoord2f(0.5f, 0.0f); glVertex3f(float(m_PosX + 1), float(m_PosY - 0.5f), 0.0f);
glTexCoord2f(0.5f, 1.0f); glVertex3f(float(m_PosX + 1) , float(m_PosY + 0.5f), 0.0f);
glTexCoord2f(1.0f, 0.5f); glVertex3f(float(m_PosX + 2) , float(m_PosY), 0.0f);


Something like this should serve to cut out the diamond shaped image from the rectangular texture, and map it onto your diamond quad. All depends on exactly how your projections and such are set up.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!