I can't say for certain without seeing your code, but it's very possible that your PNGs have premultiplied alpha -- if you're using Cocoa to load them -- and that might cause the subtle errors you're seeing.

You should dig around for the quicktime image loading code that's floating around here ( I can post my variation on it if you want ). That'll get you raw, non-premultiplied alpha.

The other issue is that Photoshop's PNG export is not too good. It's good for web, but not for OpenGL use. I can't recall what's so bad about it... but google for the SuperPNG photoshop export plugin. It's excellent.

The problem here is that photoshop uses a white background for the image. That means that the white background is visible on semitransparent parts.

There are two ways to get around this, one is to extend the colors of the opaque parts out over the transparent bits, goodness only knows how you can manage that. The other is to premultiply your image and use a premultiplied blending function. If you search the forums you'll find a thread started by Ivan which covers this in more detail.

Actually, a perfectly good way to extend the colors of your image is to make a layer behind the image in photoshop that's a merged-copy of the image and run a blur on it, or a maximum/minimum filter to "spread" it out. I do this for the foliage in my game.

But then, if you use the SuperPNG exporter and use a formal alpha channel ( in the channels palette ) this problem won't happen in the first place.

Hi, I'm the graphic artist of McSebi. Following Tomorrow's advice, I tried SuperPNG to create the PNGs and the results are the same. Jagged edges. I also used Apple's Preview and GraphicConverter. Got the same results. I never thought OpenGL would be so troublesome. And I thought the PlayStation 2 had the the worst graphic technology...

Freelance video game artist and video game compliance tester at Enzyme Testing Labs.

What I do is select the image, stroke 1 pixel on the outside with a color matching the outside of the image, and them stroke a 98% clear over top of those pictures. It fixed the premultiplied problem and the halo effect several of us have ran into.

But I seriously couldn't notice the difference between the two images before I read what they were.

Another thing to check: do you have the GL_TEXTURE_ENV_MODE for that texture set to GL_MODULATE? If it's anti-aliased with alpha, it will carry that alpha to a white quad. I'm not sure if GL_REPLACE does alpha the same way, but I'm pretty sure that GL_DECAL is RGB only.

Ok, thanks for all your input. Here is my code which generates one texture. If I try Fix 1 everything looks great when rendered onto a black background, but all my masks have gone :-) Why that?
Fix 2 is a a bit strange because I draw the image twice but this leads to a better result. It seems drawing the image with Quartz produces the problem.

TRect is a wrapper for CGRect

Code:

// CGImageRef bitmap; // Created from png using CGImageCreateWithPNGDataProvider