Strange Blending/Clearing/??

Terribly odd indeed…

I’m trying to make a basic 2D engine, and am having problems…I enabled blending using glEnable(GL_BLEND);, set glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);, am loading a TGA that I know has an Alpha bit with some transparency(I exported the transparency bit to a file, and it’s there), Texture Mapped the TGA to a quad, then tried to display it over another texture mapped quad…I loaded it last, and the Z is much higher, and I’m in glOrtho, yet there’s nothing transparent at all in the quad. It’s still just a solid block.

I’m programming in C.
I don’t understand why it’s not working…though another odd thing is that when I call glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT), and I’ve used a glColor somewhere in my main loop, the color stays…it doesn’t clear it…seriously confusing me. I have set glClearColor… Any ideas? Particularly the first problem. Thanks.

Finder

[This message has been edited by Finder (edited 04-26-2003).]

Hi,

About blending - check the glTexImage2D function for parameter GL_RGBA. Maybe the picture hasn’t transparancy background?

glClearColor doesn’t clear the color for function glColor, this function specifies the color for color buffer, that means what is the color of the screen after calling SwapBuffers.

yaro

Hey,

The glTexImage2D has GL_RGBA…still can’t figure it out
Thanks about the info for glColor.

How do you set glOrtho - specifically actual near and far parameters passed to the function and what is the z depth of your textured quad? Just want to make sure you aren’t placing the quad outside of the near and far clip planes.

Looks ok,

glOrtho(0.0,800.0,0.0,600.0,1.0,20.0);
The first textured quad(the background) is at -15.0, and the supposed to be transparent one is at -5

Thanks

Is the TGA with transaprency in front or in back? And the other textured quad… does it have alpha?

The TGA with transparency is in front. The background TGA does have alpha, but all of it is set to 1.

Was also curious if it had something to do with the poor fact that I’m running windows? Normal polies work fine blended…just not RGBA textures. I’ve statically linked the library, so I don’t see a problem…but if that is it, is there a way to fix it?

[This message has been edited by Finder (edited 04-26-2003).]

Very odd.

If you turn off blending can you see it?

Edit:
Also, are you drawing the TGA quad first or last, and do you have depth testing enabled?

[This message has been edited by shinpaughp (edited 04-26-2003).]

Sure, I can see it…the whole picture that is. Same as with blending on. Just no transparency.

the funny thing is that if I set transparency with glColor4f(1.0,1.0,1.0,0.5)…it shows it with transparency. But of course I can’t change the individual bits easily with this.
Thanks for all of the help…sorry for being a pain. ;-p

Edit:
Yes, the “transparent” quad is drawn last…and I have tried both depth testing enabled and disabled…doesn’t seem to make a difference. But normally, it is enabled.

[This message has been edited by Finder (edited 04-26-2003).]

[This message has been edited by Finder (edited 04-26-2003).]

Oh, you can see the quad, it just isn’t transparent??? Try

glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR);

Yep, I can see it. But nothing is transparent.
I did have:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
and tried the new color one…but no difference. Everything’s still opaque.
Sorry for the confusion.

[This message has been edited by Finder (edited 04-26-2003).]

Could you send me screenshots or post them.

It might take a bit of looking to find the image that’s supposed to be transparent…it’s the little cursor in the cupboard. Btw, I’ll delete this image after you view it 'cause it copywritten(used with permission)

Images usually don’t show. If you have a web page, post a link to where the image can be found there or just email them.

'k, sorry. www.mycgiserver.com/~finder83/screenshot.jpg

And should you just see the black part and the white should be transaprent?

Yeah, pretty much…it’s just supposed to be a hand cursor(will rework the artwork later. ;-p), so the inside part of the hand should be opaque while the outside white should be transparent
Which I’ve checked time and time again that the Alpha channel was right, and it is…even output its contents to a file and it lined up perfectly.

[This message has been edited by Finder (edited 04-26-2003).]

I think the problem is that OpenGL clamps the resulting fragments between 0 and 1.

edit:

Actually, try

glBlendFunc(GL_SRC_ALPHA, GL_ONE);

That should work as expected. Hope it does. Else I am out of ideas.

Good luck

[This message has been edited by shinpaughp (edited 04-27-2003).]

nope…same outcome. Going to try and read in the tga so that each bit is between 0 and 1…no idea if it’ll work but may be worth a try

Reread my post. I edited it probably after you read it first time.

I tested it with backgraound alpha = 1.0f and textured quad in front with alpha ranging from 0 to 1. Worked great.