如何在iPhone上的OpenGL ES绘图应用程序中实现撤消? [英] How would I implement undo in an OpenGL ES painting application on the iPhone?

查看:111
本文介绍了如何在iPhone上的OpenGL ES绘图应用程序中实现撤消?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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:
http://developer.apple.com/iphone/library/documentation/3DDrawing/ Conceptual / OpenGLES_ProgrammingGuide / TechniquesforWorkingwithVertexData / TechniquesforWorkingwithVertexData.html

LRU:
http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used

这篇关于如何在iPhone上的OpenGL ES绘图应用程序中实现撤消?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆