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

后端 未结 4 1704
长情又很酷
长情又很酷 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:59

    Either you can use NSUndoManager, class provided by iOS

    Or you can save current state of screen area by:

    CGContextRef current = UIGraphicsGetCurrentContext();
    

    You can have one array as stack with screen image objects and on undo action you can pop value from stack and on each change push value into the stack.

提交回复
热议问题