Jump to content
  • Advertisement
Sign in to follow this  

billboarding/transparency in opengl+sdl

This topic is 5053 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 cant seem to make textures transparent in SDL/opengl, what functions should i use to load in a bmp, and texture it to a quad such that black is transparent in SDL? THanks

Share this post

Link to post
Share on other sites
thought I would add some details...
this is what i have so far...

loading texture...
image1 = LoadBMP(filename);
image1 = SDL_DisplayFormatAlpha(image1);
SDL_SetColorKey(image1, SDL_SRCCOLORKEY,SDL_MapRGB(image1->format, 0, 0, 0));

setup tex params and such...


display textured quad....


but this code shows no transparencies...suggestions?

Share this post

Link to post
Share on other sites
I know I have to load it in with alpha, my question is how to do that in a cross platform way using SDL.

I think there are SDL functions that could convert my bmp to rgba.

Share this post

Link to post
Share on other sites
Save your image as png or other format that has RGBA format support. TGA works too, but TGA images require more disk space (a lot more).

Then load this image with SDL_Image-library or similar. Then create a new SDL_Pixelformat with RGBA masks, etc. are in the correct order. Then create a new image of the old image with the new pixelformat. Then just do glTexImage2D with the surf->pixels of the _new_ image and put GL_RGBA to the format.

If you want to stick to BMP's and colorkeys, then load the BMP, create a new pixelformat like above and blit the BMP image into the new surface and use that with glTexImage2D.

Using this method frees you from using reversed y-coordinates with glTexCoord, because the pixels are not in a reversed order like they are with BMP images.

I would post my source code, but I am not at home now and I do not have access to my files....


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!