How to achieve a palette effect on iPhone using OpenGL
- by Joe
I'm porting a 2d retro game to iPhone that has the following properties:
targets OpenGL ES 1.1
entire screen is filled with tiles (textured triangle strip
tile textured using a single 256x256 RGBA texture image
the texture is passed to OpenGL once at the start of the game
only 4 displayed colours are used
one of the displayed colours is black
The original game flashed the screen when time starts to run out by toggling the black pixels to white using an indexed palette.
What is the best (i.e. most efficient) way to achieve this in OpenGL ES 1.1?
My thoughts so far:
Generate an alternative texture with white instead of black pixels, and pass to OpenGL when the screen is flashing
Render a white poly underneath the background and render the texture with alpha on to display it
Try and render a poly on top with some blending that achieves the effect (not sure this is possible)
I'm fairly new to OpenGL so I'm not sure what the performance drawbacks of each of these are, or if there's a better way of doing this.