Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Lines can now use all 8 bits of the stencil buffer

  • Loading branch information...
commit a7a92687f87889c1474fb80a1c521ca14ff22d7a 1 parent 16429ca
@phoboslab authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 Classes/Ejecta/EJCanvas/EJPath.mm
View
16 Classes/Ejecta/EJCanvas/EJPath.mm
@@ -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];
@@ -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;
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.