def __init__ (self): w, h = director.window.get_size() print "TextureFilterEffect(%d,%d)" % (w,h) self.texture = image.Texture.create_for_size(GL_TEXTURE_2D, w, h, GL_RGBA) self._grabber = TextureGrabber() self._grabber.grab (self.texture) self.texture = self.texture.get_region(0, 0, w, h)
class TextureFilterEffect (Effect): """Base class for texture based effects. Prepare captures layer in ``self.texture``, with a window sized capture. Show just blits the texture, override to do more interesting things""" def __init__ (self): w, h = director.window.get_size() print "TextureFilterEffect(%d,%d)" % (w,h) self.texture = image.Texture.create_for_size(GL_TEXTURE_2D, w, h, GL_RGBA) self._grabber = TextureGrabber() self._grabber.grab (self.texture) self.texture = self.texture.get_region(0, 0, w, h) def prepare (self, target): self._grabber.before_render(self.texture) target.batch.draw() target.draw() self._grabber.after_render(self.texture) def show (self): """``self.texture`` contains the layer; redefine this method to show the texture applying the effect you want.""" self.texture.blit (0, 0)