Andy Franklin
Andy Franklin

Reputation: 11

Fast changing bitmap in Android

I have a thread for calculating players field of vision in my 2d game for Android. Everytime when that thread re-makes the Bitmap of field of vision and passes it to the main game loop, Bitmap blinks a little (I currently have limited FPS to 1 in the vision thread).

Could this be because of some kind of loading time when i pass the bitmap to another class? This is very annoing so I hope that you could help!

I had this calculating process before at the main game loop class, and there was no blinking, only FPS was low. Now FPS is high but the blinking is high too :)

Upvotes: 1

Views: 119

Answers (1)

Sam
Sam

Reputation: 7858

  • First be sure, that the bitmap creation and rendering threads don't interfere by checking/adding locks. Concurrent reads/writes to the bitmap would cause inconsistent renders.
  • Blinking/flickering is possibly just because of single buffered drawing. Try to enable double buffering for the rendering surface (for best performance, you'd use an OpenGL context with double buffering). Double buffering allows rendering to an invisible back buffer while the front buffer is shown on screen. After rendering is finished, the back buffer is swapped with the front buffer at once, so that there's never an incomplete image.
  • Maybe, its just because of a misplaced 'clear'.

Upvotes: 1

Related Questions