Skip to content

Commit

Permalink
Lines can now use all 8 bits of the stencil buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
phoboslab committed Nov 3, 2012
1 parent 16429ca commit a7a9268
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Classes/Ejecta/EJCanvas/EJPath.mm
Expand Up @@ -474,12 +474,9 @@ - (void)drawLinesToContext:(EJCanvasContext *)context {
EJColorRGBA color = state->strokeColor;
color.rgba.a = (float)color.rgba.a * state->globalAlpha;

// enable stencil test when drawing transparent lines
// cycle through the highest 7 bits, so that the stencil buffer only has to be cleared after seven stroke operations
// the lowest bit is reserved for drawPolygonsToContext
if(color.rgba.a < 0xff) {
stencilMask <<= 1;

// Enable stencil test when drawing transparent lines.
// Cycle through all bits, so that the stencil buffer only has to be cleared after eight stroke operations
if( color.rgba.a < 0xff ) {
[context flushBuffers];
[context createStencilBufferOnce];

Expand Down Expand Up @@ -720,17 +717,20 @@ - (void)drawLinesToContext:(EJCanvasContext *)context {
} // for each path

// disable stencil test when drawing transparent lines
if(color.rgba.a<0xff) {
if( color.rgba.a < 0xff ) {
[context flushBuffers];
glDisable(GL_STENCIL_TEST);

if(stencilMask == (1<<7)) {
if( stencilMask == (1<<7) ) {
stencilMask = (1<<0);

glStencilMask(0xff);
glClearStencil(0x0);
glClear(GL_STENCIL_BUFFER_BIT);
}
else {
stencilMask <<= 1;
}
}
}

Expand Down

0 comments on commit a7a9268

Please sign in to comment.