How would I implement undo in an OpenGL ES painting application on the iPhone?

后端 未结 4 1701
长情又很酷
长情又很酷 2020-12-15 11:37

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.

4条回答
  •  佛祖请我去吃肉
    2020-12-15 11:48

    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

提交回复
热议问题