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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With