How to achieve a palette effect on iPhone using OpenGL

Posted by Joe on Stack Overflow See other posts from Stack Overflow or by Joe
Published on 2010-04-09T10:58:44Z Indexed on 2010/04/09 15:23 UTC
Read the original article Hit count: 339

Filed under:
|
|

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:

  1. Generate an alternative texture with white instead of black pixels, and pass to OpenGL when the screen is flashing
  2. Render a white poly underneath the background and render the texture with alpha on to display it
  3. 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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about opengl-es