5

I am trying to implement svg rendering by opengl using meshes. In paths with opacity less than 1, the color of overlapping strokes add up.

![enter image description here

But it should be like this

enter image description here

the opengl calls are:

    glDepthMask(false);
    glEnable(GL20.GL_BLEND);
    glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ....
    glDrawArrays(....);
    ....
    glDepthMask(true);

is there any opengl calls, shader or other method to have same transparent value around the whole stroke without modifying the geometry of the shape?

1 Answers1

3

You can use the depth buffer to ensure that the second time you get on a point the pixels aren't written.

You start with the maximum depth value and each new path (that you want to add to the existing drawn image) you decrement the depth.

ratchet freak
  • 5,950
  • 16
  • 28