views:

64

answers:

1

I'm getting some intermittent bottlenecks on my 2D OpenGL ES iPhone game. When I profiled it in Shark, nothing remarkable came up. In the game, the background takes up the whole screen and I have about 7-8 smaller sprites continuously moving across the screen. For the most part it runs smoothly, but every now and then I'll get a small frame stutter. Is this a common issue with games that have constant movement?

Also, as a side note, I am calling glClear(GL_COLOR_BUFFER_BIT); after each frame is rendered. If I leave this out, I still get some occasional frame skipping, but it's less frequent than if I leave the glClear call in. I'm also using a single spritesheet texture for all my game sprites.

+1  A: 

How are you managing your screen refreshes? Maybe you're not exactly synchronized to the display refresh rate. If you're not already, I'd recommend using CADisplayLink to match your refreshes to the display's. Apple's latest OpenGL ES template shows how to do this.

Brad Larson
I probably wasn't synched to the display refresh rate. I was calling [NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(mainGameLoop) userInfo:nil repeats:NO];and I then made the same call at the end of my mainGameLoop function (thus causing a slight delay in my loop and reserving cpu resources).CADisplayLink looks promising. I'm going to try implementing this tonight.
Scott