Open cmaughan opened 8 years ago
Yes, the stencil is assumed to be cleared to 0.
The relevant code is here: https://github.com/memononen/nanovg/blob/master/src/nanovg_gl.h#L943
In the chunk which draws stuff with color mask false, does the even/odd thing. The expected result is that the regions outside the shape are 0.
Then the AA fringe is drawn, only the pixels outside the shape get written. The shape is inset by half a pixel earlier to make this work.
And finally the fill is drawn, clearing the stencil to 0 is it goes.
That makes sense, thanks. I had missed that the final fill re-clears the stencil. Clever ;)
I recently debugged a difference between D3D and GL rendering. It turned out that the D3D renderer was clearing the stencil to 1, but the GL was clearing to 0. I thought nanovg didn't care about the initial state, but I guess not. Just checking - is the assumption that each frame the stencil is cleared to 0?