Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


2D tilemap in OpenGL

This topic is 5532 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

Hi guys. I''ve been porting a 2d tile world game across to Open GL, and things are going pretty nicely. I display the tiles as a set of quads in orthogonal mode to avoid any depth concerns, and it works nicely. But I''d love it if I could blend between my tiles (say grass to forest, for instance) automatically without having to create a million edge tiles and so on. Is this logical and easy to do in OpenGL? Has anyone else been doing 2d tile maps, and if so, what methods do you use for displaying your tiles?

Share this post

Link to post
Share on other sites
Thanks for the link, and that is almost what I am doing at present.
I was hoping for a nice OpenGL hardware accelerated method that would automatically blend between two base tiles. Of course I wouldn''t get nice corners, and so on, but if possible it would allow for automated blending between two different types of base tyles without having to specifically handle the creation of corner graphics myself.

Share this post

Link to post
Share on other sites
if I get you right..

you will have to draw the base (bottom) tile first with no blending..

and then draw the second tile

after using the following..

glEnable(GL_BLEND); // Enable Blending

that will blend in top tile to the bottom tile at 50% (it also allows you to fade in a tile (or fade it out)

you will probably have the change you alpha matching function value so it works with the adjusted alpha of the second tile.. Ie. most people use glAlphaFunc(GL_GREATER,0.9f) but if you want to draw the second tile (at .5f alpha) then set your alpha funct to .4

hope that helps


Share this post

Link to post
Share on other sites

  • 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!