如何使用OpenGL在iPhone上实现调色板效果

发布于 2024-08-27 21:34:13 字数 532 浏览 3 评论 0原文

我正在将一个 2D 复古游戏移植到 iPhone,它具有以下属性:

  • 目标 OpenGL ES 1.1
  • 整个屏幕充满图块(
  • 使用单个 256x256 RGBA 纹理图像进行
  • 纹理化的纹理三角形条图块纹理在开始时传递到 OpenGL)游戏
  • 仅使用 4 种显示颜色,
  • 其中一种显示颜色是黑色

当时间开始用完时,原始游戏通过使用索引调色板将黑色像素切换为白色来闪烁屏幕

什么是最好(即最有效)的方法 。在 OpenGL ES 1.1 中实现这一点?

到目前为止我的想法:

  1. 生成一个带有白色而不是黑色像素的替代纹理,并在屏幕闪烁时传递给 OpenGL
  2. 在背景下方渲染一个白色多边形并使用 alpha 渲染纹理以显示它
  3. 尝试并在顶部渲染一个多边形,并通过一些混合来实现效果(不确定这是否可能)

我对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 each of these are, or if there's a better way of doing this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笨死的猪 2024-09-03 21:34:13

最后,我在纹理的空闲空间内复制了图块/精灵,并简单地从纹理的这部分进行渲染。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文