From 3ee86ba58ec4ad3d17af248c492eae518dab3cd8 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 1 Mar 2011 19:33:43 +0100 Subject: [PATCH] bindtexture: allow to set a texture on another texture unit --- kivy/graphics/context_instructions.pxd | 2 +- kivy/graphics/context_instructions.pyx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kivy/graphics/context_instructions.pxd b/kivy/graphics/context_instructions.pxd index 0838495a2..13756b4fd 100644 --- a/kivy/graphics/context_instructions.pxd +++ b/kivy/graphics/context_instructions.pxd @@ -13,11 +13,11 @@ cdef class Color(ContextInstruction): cdef void apply(self) cdef class BindTexture(ContextInstruction): + cdef int _index cdef str _source cdef Texture _texture cdef void apply(self) - cdef class PushMatrix(ContextInstruction): cdef void apply(self) diff --git a/kivy/graphics/context_instructions.pyx b/kivy/graphics/context_instructions.pyx index b95d59350..db2a2dca5 100644 --- a/kivy/graphics/context_instructions.pyx +++ b/kivy/graphics/context_instructions.pyx @@ -200,9 +200,11 @@ cdef class BindTexture(ContextInstruction): if self.source is None: self.texture = kwargs.get('texture', None) + self.index = kwargs.get('index', 0) + cdef void apply(self): cdef RenderContext context = self.get_context() - context.set_texture(0, self._texture) + context.set_texture(self._index, self._texture) property texture: def __get__(self): @@ -212,6 +214,15 @@ cdef class BindTexture(ContextInstruction): texture = get_default_texture() self._texture = texture + property index: + def __get__(self): + return self._index + def __set__(self, int index): + if self._index == index: + return + self._index = index + self.flag_update() + property source: '''Set/get the source (filename) to load for texture. '''