示例#1
0
文件: frame.py 项目: cheery/essence
class Overlay(object):
    def __init__(self, frame, renderer):
        self.frame = frame
        self.frame.overlays.add(self)
        self.renderer = renderer
        self.texture = Texture.empty()
        self.texture.resize(frame.width, frame.height)
        self.framebuffer = Framebuffer(self.texture)
        self.dirty = True

    def update(self, argon):
        texture = self.texture
        if texture.width != self.frame.width or texture.height != self.frame.height:
            texture.resize(self.frame.width, self.frame.height)
        argon.render.output = self.framebuffer
        argon.render.bind()
        self.renderer(argon)
        argon.render.output = argon
        argon.render.bind()

    def render(self, argon):
        if self.dirty:
            self.update(argon)
            self.dirty = False
        argon.render.rectangle(self.frame.rect, self.texture)

    def free(self):
        self.texture.free()
        self.framebuffer.free()
        self.frame.overlays.remove(self)
示例#2
0
文件: frame.py 项目: cheery/essence
 def __init__(self, frame, renderer):
     self.frame = frame
     self.frame.overlays.add(self)
     self.renderer = renderer
     self.texture = Texture.empty()
     self.texture.resize(frame.width, frame.height)
     self.framebuffer = Framebuffer(self.texture)
     self.dirty = True