Win a copy of Securing DevOps this week in the Security forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Choppy animation in android OpenGL Game Loop  RSS feed

Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Really hoping someone can help me out here. I've written an android Open GL ES 2.0 game and my logic update calls and rendering calls are running on the GL Rendering thread. I'm also using a fixed time delta, not variable.

The code for my loop is below. The problem is that the animation just isn't smooth. It will run for a second or 2 smoothly, then it will become 'choppy' for a little while, then return to normal.

The 'choppiness' is present if the sprite is moving fast or slow, but is a lot more noticeable with faster moving sprites.

I have 2 test devices, a Google Nexus 10 running KitKat and an old Samsung Galaxy Ace running Gingerbread. Now, if I change my 'maxFramesSkip' value from 5 to 1 it runs perfectly on my Nexus 10, however, on the Galaxy Ace, it seems to speed up and slow down, so I changed it back to 5. At andvalue other than 1, the animation is choppy.

I've tried interpolation but this has no effect. I've included my code here for that too.

I can't understand why this is happening. I should point out that my rendering takes a maxumum of 14ms to complete and the logic updates take a maximum of 4ms to complete. So there should be no frame skipping. I'm therefore wondering if there is something wrong with my loop? I'v spent literally months trying various things, but nothing produces smoother animation. So i'm hoping someone with a better understanding of game loops can help me out!!

Any help would be apprecated!

Main Game Loop

Interpolation in render()

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!