4
$\begingroup$

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?

$\endgroup$
3
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.