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

查看:15
本文介绍了如何在 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天全站免登陆