tags:

views:

1395

answers:

2

I'm making a simple 2D game for the iPhone. It's based on CrashLanding... so it's basically a background texture and a few rectangular textures moving around.

I have this bizarre little graphics problem: some of the small 2d items (can assume just rectangles) moving around get this little flashing black bar on top of them (the background texture is almost completely white so the little bar is noticable).

The textures I'm using are small (~1Kb) pngs.

Has anyone else run into this? Is this a common openGL issue? Thanks very much!

btw this happens on both the simulator and the actual device.

+5  A: 

Do you have a thing like that little black bar in your textures?

I've encountered similar problems when I have done something wrong. Here's a small check-list:

  • Have you have mipmapped your texture or not, and check what parameters does it have.
  • glTexParameters. (WRAP_S, WRAP_T, MAG_FILTER, MIN_FILTER...)
  • texture's dimensions. (If there's non-power-of-two -textures allowed, it may cause graphic glitches, depending about how you load your textures)
  • Are you are drawing that flashing bar on top of your rectangles?
  • Whether there's something that's causing the black bar, in your texture.
  • Alignment of the animation frames.
  • Blending and alpha-blending.

If something in the list is vague for you, it's good exercise to read about them.

I also do a good guess: I believe you aren't wrapping your textures in any direction, and that the animation frames are a bit misaligned, so that your application has a bit wrong texture coordinates/height in the quad you are drawing.

I hope my advices make sense. I have only experience with the usual opengl, not the OpenGL ES that's graphics pipelines have been pruned to make it more compact, cleaner and more elegant.

Cheery
A: 

Since this is a 2D game, are these small rectangular sprites contained within the same texture sheet? Another possible culprit could be texture filtering.

If you are trying to manipulate texture coordinates to draw a subregion of your texture, you could check if you are drawing the sprite at a larger than 1:1 ratio. If you have linear texture filtering enabled (as opposed to nearest), OpenGL may grab some pixels from the adjacent sprite if you try to scale the sprite beyond 1:1.

If this is the case, you might try placing a 1 pixel buffer in your texture sheet in between sprites.