bindtexture: allow to set a texture on another texture unit

This commit is contained in:
Mathieu Virbel 2011-03-01 19:33:43 +01:00
parent b5f9d9592d
commit 3ee86ba58e
2 changed files with 13 additions and 2 deletions

View File

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

View File

@ -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.
'''