I am using OpenGL and the GLPaint example. I created an application that applies a swirl on the image (texture) when the user touches the image. I have a problem that I need to save the first stroke, and then apply the next step and so on. But with the next touch, the previous applied effect is deleted.
I tried to use the depth buffer and frame buffer, but could not get the desired result. I attach all my code and shaders
Also add a shader as follows:
precision highp float; varying vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform vec2 center; uniform float radius; uniform float angle; void main() { vec2 textureCoordinateToUse = textureCoordinate; float dist = distance(center, textureCoordinate); if (dist < radius) { textureCoordinateToUse -= center; float percent = (radius - dist) / radius; float theta = percent * percent * angle * 8.0; float s = sin(theta); float c = cos(theta); textureCoordinateToUse = vec2(dot(textureCoordinateToUse, vec2(c, -s)), dot(textureCoordinateToUse, vec2(s, c))); textureCoordinateToUse += center; } gl_FragColor = texture2D(inputImageTexture, textureCoordinateToUse ); }
Please help me debug what is wrong and how to solve this problem.
You can also run the full Twirl on Touch-github project.
source share