PDA

View Full Version : tranparency



emshelly
05-22-2002, 06:01 PM
I'm trying to draw a transparent bubble by texture map a rectangle with an image of a bubble, and then make them transparent. In fact, I have made it work on my computer and my friend's. But at many other computers, the tranparency doesn't work. Does anybody know how could something be transparent on one machine and not on others?

Here is part of my code where I texture map the image:

GLubyte *bits;
BITMAPINFO *info;

bits = LoadRGBA("Data/bubble5.bmp", &info);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glTexImage2D(GL_TEXTURE_2D, 0, 3, info->bmiHeader.biWidth,
info->bmiHeader.biHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, bits);

glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBegin(GL_POLYGON);

glTexCoord2f(0.0, 0.0); glVertex3f(xPos, yPos, 0.0);
glTexCoord2f(1.0, 0.0); glVertex3f(xPos + rSize, yPos, 0.0);
glTexCoord2f(1.0, 1.0); glVertex3f(xPos + rSize, yPos + rSize, 0.0);
glTexCoord2f(0.0, 1.0); glVertex3f(xPos, yPos + rSize, 0.0);
glEnd();
glDisable(GL_BLEND);

Thanks!

yakuza
05-23-2002, 04:49 AM
If this is also you...
http://www.gamedev.net/community/forums/topic.asp?topic_id=95713

You never responded to the posters (like myself) that asked you questions and offered some ideas. Why don't you re-read through that thread and see if my suggestion of changing to glBlendFunc(GL_SRC_ALPHA, GL_ONE) doesn't help?

[This message has been edited by yakuza (edited 05-23-2002).]

secnuop
05-23-2002, 08:09 AM
.BMPs don't have an alpha channel. So as far as the alpha values for your texture go, they're all 1.0. This isn't necessarily a bad thing, but it is something you should be aware of.

What are you setting the current color to? Are you modulating it with the texture? What is your blend equation? I'd imagine that with blending mode FUNC_ADD, the current color set to (1,1,1,0.5), and with it being modulated with the texture you should be fine (this is how it's done in nehe's blending tutorial).

It seems weird that it works on some systems but not on others. What's different about the systems that it is failing on?

phil_24284
05-23-2002, 12:20 PM
probably itīs because of the following:
glTexImage2D(GL_TEXTURE_2 ,0 ,4 ...
4 because of rgba but you set 3.
Phil