Sign in to follow this  

billboarding/transparency in opengl+sdl

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

thought I would add some details...
this is what i have so far...

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

setup tex params and such...

</code>

display textured quad....

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER,0);
glBindTexture(GL_TEXTURE_2D,tex);
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(-1,-1,0);
glTexCoord2f(1,0);
glVertex3f(1,-1,0);
glTexCoord2f(1,1);
glVertex3f(1,1,0);
glTexCoord2f(0,1);
glVertex3f(-1,1,0);
glEnd();
glDisable(GL_ALPHA_TEST);
glDisable(GL_BLEND);



but this code shows no transparencies...suggestions?

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....

-Richardo

Share this post


Link to post
Share on other sites

This topic is 4772 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this