如何在 iPhone 上的 OpenGL ES 中设置/获取纹理上的像素?

发布于 2024-08-22 12:26:19 字数 131 浏览 4 评论 0 原文

我试图用谷歌搜索标题中提到的内容,但不知何故我找不到它。这不应该那么难,不是吗?

我正在寻找一种在 iPhone 上访问 OpenGL ES 纹理的方法,以及一种使用它获取/设置像素的方法。我正在寻找哪些 OpenGL ES 函数?

I am trying to Google for what I've mentioned in the title, but somehow I couldn't find it. This should not be that hard, should it?

What I am looking for is a way to gain access to an OpenGL ES texture on iPhone, and a way to get/set pixel with it. What are the OpenGL ES functions I am looking for?

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

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

发布评论

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

评论(2

少女七分熟 2024-08-29 12:26:19

在 OpenGL ES 能够看到您的纹理之前,您应该已经将其加载到内存中,生成纹理名称(glGenTextures)并绑定它(glBindTexture)。你的纹理数据只是内存中的一个大数组。

因此,如果您要更改单个纹素,您可以在内存中操作它,然后再次绑定它。这种方法通常用于程序纹理生成。网上有许多关于它的可用资源,例如: http://www.blumtnwerx.com/blog/2009/06/opengl-es-texture-mapping-for-iphone-oolong-powervr/

虽然 glReadPixels 可用,但在极少数情况下,您需要将它用于交互式应用程序(想到屏幕捕获)。它绝对会破坏性能。并且仍然不会返回原始纹理,而是返回帧缓冲区的块。

我不知道你想要什么样的效果。但是,如果您的目标设备支持像素着色器,那么自定义像素着色器也许可以满足您的需求。

当然,我正在假设您并不是指屏幕坐标中的像素。

Before OpenGL ES is able to see your texture, you should have loaded it in memory already, generated texture names(glGenTextures), and bound it(glBindTexture). Your texture data is just a big array in memory.

Therefore, should you with to change a single texel, you can manipulate it in-memory and then bind it again. This approach is usually done for procedural texture generation. There are many available resources on the net about it, for instance: http://www.blumtnwerx.com/blog/2009/06/opengl-es-texture-mapping-for-iphone-oolong-powervr/

While glReadPixels is available, there are very few situations where you'd need to use it for interactive applications(screen capture comes to mind). It absolutely destroys performance. And still won't give you back the original textures, but instead will return a block of the framebuffer.

I have no idea what kind of effect you are looking for. However, if you are targeting a device that supports pixel shaders, perhaps a custom pixel shader can do what you want.

Of course, I am working under the assumption you didn't mean pixel as in screen coordinates.

等你爱我 2024-08-29 12:26:19

我不知道如何设置单个像素,但 glReadPixels 可以从帧缓冲区读取像素块(http://www.khronos.org/opengles/sdk/docs/man/glReadPixels.xml)。您的谷歌搜索问题可能是因为纹理像素通常被缩短为“纹理像素”。

I don't know about setting an individual pixel, but glReadPixels can read a block of pixels from the frame buffer (http://www.khronos.org/opengles/sdk/docs/man/glReadPixels.xml). Your problem googling may be because texture pixels are often shortened to 'texels'.

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