将任意大小的像素块复制到 OpenGL ES 纹理中...不知何故?
我正在编写一个绘图应用程序,绘图画布是 OpenGL 纹理。 当您在画布上绘制时,它会确定画布纹理的哪个区域已更改,并在应用您所做的更改之前复制该像素数据(使用 glReadPixels)。
要撤消,我想简单地使用复制出来的像素数据恢复到以前的纹理状态。 但是,OpenGL ES 不提供 glDrawPixels 命令。 最好的方法是什么?
我考虑过两个选项,但我不确定其中一个是否那么好:
使用我复制出来的像素创建临时纹理并将其绘制出来。(但是,复制的区域不是 2 的幂!)< /p>
完全解除大画布纹理的绑定,手动更改纹理的字节,然后然后将其放回OpenGL。 我没有使用任何形式的压缩,所以这可能没那么糟糕。 但这似乎是一种黑客行为?
有人有什么想法吗? 我真的很感激!
I'm writing a drawing application, and the drawing canvas is an OpenGL texture. When you draw onto the canvas, it determines which region of the canvas texture has been changed, and copies that pixel data out (using glReadPixels) before applying the changes you made.
To undo, I want to simply revert to the previous texture state using that pixel data that was copied out. However, OpenGL ES doesn't provide a glDrawPixels command. What's the best way to do it?
I've considered two options, but I'm not sure either is that great:
Create a temporary texture using the pixels I copied out and draw that in. (However, copied region is not a power of two!)
Unbind the large canvas texture completely, manually alter the bytes of the texture, and then put it back into OpenGL. I'm not using any sort of compression, so this might not be that bad. But it seems like a hack?
Anybody have any ideas? I'd really appreciate it!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人在尝试做类似的事情时偶然发现这个问题,我已经想出了一个似乎运作良好的解决方案。
我认为这是一种相当缓慢的处理方式,但我不需要巨大的性能 - 我真正关心的是限制表示“旧”纹理的数据量。
如果您需要这方面的帮助(有相当多的代码),请随时给我发电子邮件。
In case anyone stumbles across this while trying to do something similar, I've come up with a solution that seems to work well.
I think this is a pretty slow way of going about things, but I don't need huge performance - my real concern was limiting the amount of data being kept to represent the "old" texture.
If you need help with this (there's quite a bit of code) feel free to email me.