MrDatabase
MrDatabase

Reputation: 44505

How can I get rid of artifacts in my OpenGL ES iPhone app?

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.

Upvotes: 1

Views: 827

Answers (2)

Ben Gotow
Ben Gotow

Reputation: 14893

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 :-)

Upvotes: 5

Nosredna
Nosredna

Reputation: 86356

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.

Upvotes: 1

Related Questions