stencilinstruction: add the possibility to configure the stencil glop code

This commit is contained in:
Mathieu Virbel 2012-09-22 00:47:46 +02:00
parent a217c363bc
commit 71ac8e263d
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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):