From 71ac8e263d6e90461e6dc787d6cf1b12268e8290 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Sat, 22 Sep 2012 00:47:46 +0200 Subject: [PATCH] stencilinstruction: add the possibility to configure the stencil glop code --- kivy/graphics/stencil_instructions.pxd | 11 +++++++++++ kivy/graphics/stencil_instructions.pyx | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 kivy/graphics/stencil_instructions.pxd diff --git a/kivy/graphics/stencil_instructions.pxd b/kivy/graphics/stencil_instructions.pxd new file mode 100644 index 000000000..1cf556e4c --- /dev/null +++ b/kivy/graphics/stencil_instructions.pxd @@ -0,0 +1,11 @@ +from kivy.graphics.instructions cimport Instruction + +cdef class StencilPush(Instruction): + cdef void apply(self) +cdef class StencilPop(Instruction): + cdef void apply(self) +cdef class StencilUse(Instruction): + cdef unsigned int _op + cdef void apply(self) +cdef class StencilUnUse(Instruction): + cdef void apply(self) diff --git a/kivy/graphics/stencil_instructions.pyx b/kivy/graphics/stencil_instructions.pyx index 092fe3146..6ea16d7e2 100644 --- a/kivy/graphics/stencil_instructions.pyx +++ b/kivy/graphics/stencil_instructions.pyx @@ -147,11 +147,14 @@ cdef class StencilUse(Instruction): '''Use current stencil buffer as a mask. Check module documentation for more information. ''' + def __init__(self, **kwargs): + super(StencilUse, self).__init__(**kwargs) + self._op = kwargs.get('op') or GL_EQUAL cdef void apply(self): global _stencil_in_push _stencil_in_push = 0 glColorMask(1, 1, 1, 1) - glStencilFunc(GL_EQUAL, _stencil_level, 0xff) + glStencilFunc(self._op, _stencil_level, 0xff) glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP) cdef class StencilUnUse(Instruction):