Code Monkey home page Code Monkey logo

opengl_undo's Introduction

OpenGL_UNDO

Support UNDO in openGL

Note - the code is still being used by commercial tools so it can not be published here. I'm just puting the ideas of how to do it.

JERRY OPENGL ES UNDO IMPLEMENTATION

OPENGL (for opengl es 1.1) only allows you to draw things into the buffer while it does not support the UNDO function. So there is no perfect native support.

Here - drawing of paint brush needs to be able to get function of undo. While obvioulsy we can come up with such idea:

  1. record all the drawing step's information.
  2. ignore last one when undo happens. (not delete - remember redo)
  3. clear the screen and re-draw everything.

but this is ofcourse heavy operation - when people draws over 20 lines (very likely case), it could take over 5 seconds or more to do so.

So my current solution is - instead of drawing everything everytime, let's copy the buffer for certain number of step's distance:

  1. draw and record.
  2. if it has already drawed N step without copy buffer, then save the buffer to texture.
  3. when user do undo, find the nearest buffer texture, store it back to screen, then draw the left over strokes (which is less than N for sure).

This is a trade of memory space and efficiency, however, due to the fact that texture's size needs to be power of 2, every copy of buffer needs to add 102410244 size. so - image you have like 10 buffer stored - 40M space! ;-( No idea how to improve...

Another note is.. stored image from glpixel to texture is upside down. needs to glroate and gltranslate after putting into view.

opengl_undo's People

Contributors

realzzz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.