OpenGL ES Simple undo last drawing

I'm trying to figure out how to implement a simple “undo” of the last drawing action on the iPhone screen. I draw by first creating a frame buffer:

[EAGLContext setCurrentContext:context];
glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);

Then I will prepare an array of vertices and draw this path:

glVertexPointer(2, GL_FLOAT, 0, vertexBuffer);
glDrawArrays(GL_POINTS, 0, vertexCount);
glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
[context presentRenderbuffer:GL_RENDERBUFFER_OES];

How easy is it to undo this last action? There must be a way to preserve the previous state or built-in function of OpenGL ES, I would think.

thank

+1
source share
2 answers

Late answer, which I know, but if someone else does, I will send it anyway.

You also have the option of storing points in an array every time you touch Began and touch the call to movd. Like here:

[currentStroke addObject:[NSValue valueWithCGPoint:point]];

And when touchsEnded, you can move this to another mutable array, for example:

[allPoints addObject:allCurrentStroke];

allPoints, . . -, ... , . GL_POINTS, , , , ... ! , , ... - , , !

+1

All Articles