Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are good techniques for high performance full screen bit-blitting on iOS?

Tags:

ios

iphone

ios4

Assume I want to program a Star Field animation. Not by using OpenGL but by drawing directly to the screen buffer or to off-screen buffers that can be placed on screen.

That Star Field demo running on the TRS-80 is of course just an example. Think video decoding or full-screen animations as other possibilities where rates of 20+ frames per second are needed.

What are good techniques for doing this? I am interested in both official and private API implementations.

If you can, please show some basic code.

like image 996
Stefan Arentz Avatar asked Nov 05 '22 09:11

Stefan Arentz


1 Answers

Here's a brief outline of one common and reasonably fast method.

During initialization, use CGBitmapContextCreate() to create at least 2 bitmap contexts from pointers to off-screen memory buffers, and add a CALayer as a sublayer of your UIView.

In your render loop, alternate your double buffer use, copy into and/or modify the current off-screen memory buffer, use CGBitmapContextCreateImage() to create an image from that buffer, and assign the resulting image to the CALayer contents.

like image 174
hotpaw2 Avatar answered Nov 11 '22 07:11

hotpaw2