Hi,
I'm working on a kind of drawing / painting application. Currently I have done:
- capturing user touches
- calculation of cubic bezier spline controlpoints, so that the curve is smooth in all captured touch points (constant first and second derivative -> constant slope)
- breaking the resulting curves in equal (segment can vary as needed) length segments, based on arclength approximation
But now I have some trouble to draw the resulting line correctly. What did I try:
(1) Point sprites OES (GLPaint example / CCParticleSystemPoint). This is really slow on the iPad, espacially with large line width (oh I forgot, iPad only app).
(2) Drawing GL_TRIANGLES with overlapping quads. This works pretty well when I break the line into really small segments. With about 1px segment size you get a pretty nice filled line. I can even strech the line to get a stamp like effect (the texture is placed without overlapping).
The problem here is opacity. When overlapping the quads are drawn multiple times over each other (the texture is a circle). So it is getting darker and darker... But I want the texture in one stroke to be the same opacity at all quads, even if they overlap. opacity should influence only the background (CCRenderTexture). So constant opacity.
I tried several blending modes, but without success. Can this be solved with blending modes?
(3) I did also triangulate the line and draw it as a GL_TRIANGLE_STRIP. But this approach has the same problems with opacity as (2). Furthermore there are small glitches/holes in the curve when the slope is changing rapidly. Ok it is faster as approach (2), but to solve the problems with these holes I think I need to work with degenerated triangles (and I hate that).
Any suggestion how to solve (2) with blending? Or would you suggest to follow (3)?
Thank you very much.
P.S. I'm not making another painting app ... and no line drawing game, too. :) But maybe someone "knows" how they do the texturing in e.g. Sketchbook or Brushes. Do they use (1)/(2) or (3) - or even something totally different?