Jump to content
  • Advertisement


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

Alexandre Brien

problem with some textures in my tile engine

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

Hey, just ran in a problem in a tile-based engine im working on (like the older final fantasys) the way i draw my tiles is by applying a texture (.bmp) to a quad. So the world map is hundreds of quads with textures on em. My problem is that my character texture (the character that walks on the map) is square too, and it's ugly because I cant get the unused part of the texture to be invisible, so basically I have a square running around the map =( any ideas?? does the .bmp format allows transparency or something?? heres what I mean: http://pages.infinit.net/mnok/tileproblem.jpg [edited by - Alexandre Brien on June 9, 2002 6:12:38 AM]

Share this post

Link to post
Share on other sites
The easiest solution would be to use 32 bit textures. Set the alpha channel to white for opaque pixels and black for transparent ones. Then, before you draw your sprites (but not your tiles), you just use glAlphaFunc( GL_GREATER, 0.5f) (remember to also call glEnable( GL_ALPHA_TEST))to draw only the pixels with a great enough alpha value.

You can''t use BMP to achieve this. TGA and PNG are good solutions. There''s a NeHe''s tutorial which deals with TGA loading.

Share this post

Link to post
Share on other sites
ok I switched to TGA and got it working again, but for my tiles that are 32-bit and that needs transparency, they dont show at all =)

Is there anything specific I need to do in photoshop??
What I do is create a new image, I set it to RGB(theres no RGBA options) with transparent content. Then I paste my tile there and lasso out everything that needs to be out. Then I save to .tga with 32 bit, but for some reason it fills up the transparent area with white...

heres what I do in the app (note that it doesnt work with any setting of glAlphaFunc (0 to 1)):

glAlphaFunc(GL_GREATER, 0);

//characters need to be transparents.


//map tiles dont need to be transparent.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
You''ve to add a new channel for your image (photoshop->channels->add, on the right side windows somewhere) - this is the alpha channel. Set to black where you want your image to be transparent, and white where it''s opaque (and anything inbetween for translucency)


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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!