问题描述
我正在使用Apple的示例应用程序GLPaint作为OpenGL ES绘图应用程序的基础,但我无法弄清楚如何在其中实现撤消功能。
I'm using Apple's sample application GLPaint as a basis for an OpenGL ES painting application, but I can't figure out how to implement undo functionality within it.
我不想拍摄每一笔画并存储它们。有没有办法使用不同的帧缓冲对象来实现撤销?对于更好的方法,您有其他建议吗?
I don't want to take images of every stroke and store them. Is there any way of using different frame buffer objects to implement undo? Do you have other suggestions for better ways of doing this?
推荐答案
使用顶点缓冲区对象(VBO)渲染内容。在每个新笔划上,将最后一个VBO复制到最近最少使用(LRU)列表。如果您的LRU已满,请删除最近最少使用的VBO。要恢复(撤消)最后一个笔划,只需使用最近使用的LRU的VBO并进行渲染。
Use vertex buffer objects (VBO) to render your content. On every new stroke copy the last VBO to some least recently used (LRU) list. If your LRU is full, delete the least recently used VBO. To restore (undo) the last stroke just use the most recently used VBO of the LRU and render it.
VBO:
LRU:
这篇关于如何在iPhone上的OpenGL ES绘图应用程序中实现撤消?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!