开发者

How to achieve a palette effect on iPhone using OpenGL

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 ea开发者_运维知识库ch of these are, or if there's a better way of doing this.


In the end I duplicated the tiles/sprites within the spare space of the texture, and simply render from this part of the texture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜