views:

363

answers:

2

I'm using the Texture2D class from the CrashLanding sample code. I'm getting strange artifacts around my images in both the simulator and the phone. The artifacts are little gray borders around the textures. The borders are inconsistent and do not surround the entire texture. I'm using pngs.

+1  A: 

Are your textures all powers of two in width and height? If not, that's probably your problem.

I also had problems with textures smaller than a certain size. I remember someone said that for small textures, clear the memory after it's allocated. Changing malloc to calloc in the Texture2D source fixed the problem.

Nosredna
Texture2D should take care of the non-pot images.
zoul
Should, perhaps. But doesn't. At least not the Texture2D from CrashLanding that I had.
Nosredna
+4  A: 

Hey MrDatabase - It sounds like the problem is that your texture images have premultiplied alpha. I've had this problem on the iPhone too - the PNG compression that it performs when you build your app automatically premultiplies all the alpha values. If you're using glBlend(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA), you're basically applying the alpha twice - try using glBlend(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) instead. There's lots of stuff in the Apple forums about this :-)

Ben Gotow
Awesome this works! Thanks so much :-)
MrDatabase
Thanks, spent a while trying to figure this one out with different combinations.
Mike Weller