コード例 #1
0
    def draw(self, frame):
        # The gneneral plan here is:
        #  1. Get the dots in the range of 0-255.
        #  2. Create a texture with the dots data.
        #  3. Draw the texture, scaled up with nearest-neighbor.
        #  4. Draw a mask over the dots to give them a slightly more realistic look.

        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glLoadIdentity()

        # Draw the dots in this color:
        #gl.glColor3f(1.0, 0.5, 0.25)

        gl.glScalef(1, -1, 1)
        gl.glTranslatef(0, -DMD_SIZE[1]*DMD_SCALE, 0)

        #data = frame.get_data_mult()
        
        #this new jk_get_data will read the dots using the dmd function
        #and convert them via the map to rGB.
        data = self.jk_get_data(frame)

        image = pyglet.image.ImageData(DMD_SIZE[0], DMD_SIZE[1], 'RGB', data, pitch=DMD_SIZE[0] * 3)  

        gl.glTexParameteri(image.get_texture().target, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        image.blit(0, 0, width=DMD_SIZE[0]*DMD_SCALE, height=DMD_SIZE[1]*DMD_SCALE)

        del image

        gl.glScalef(DMD_SCALE/float(MASK_SIZE), DMD_SCALE/float(MASK_SIZE), 1.0)
        gl.glColor4f(1.0, 1.0, 1.0, 1.0)
        self.mask_texture.blit_tiled(x=0, y=0, z=0, width=DMD_SIZE[0]*MASK_SIZE, height=DMD_SIZE[1]*MASK_SIZE)
コード例 #2
0
    def draw(self, frame):
        # The gneneral plan here is:
        #  1. Get the dots in the range of 0-255.
        #  2. Create a texture with the dots data.
        #  3. Draw the texture, scaled up with nearest-neighbor.
        #  4. Draw a mask over the dots to give them a slightly more realistic look.

        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glLoadIdentity()

        # Draw the dots in this color:
        #gl.glColor3f(1.0, 0.5, 0.25)

        gl.glScalef(1, -1, 1)
        gl.glTranslatef(0, -DMD_SIZE[1] * DMD_SCALE, 0)

        #data = frame.get_data_mult()

        #this new jk_get_data will read the dots using the dmd function
        #and convert them via the map to rGB.
        data = self.jk_get_data(frame)

        image = pyglet.image.ImageData(DMD_SIZE[0],
                                       DMD_SIZE[1],
                                       'RGB',
                                       data,
                                       pitch=DMD_SIZE[0] * 3)

        gl.glTexParameteri(image.get_texture().target,
                           gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
        image.blit(0,
                   0,
                   width=DMD_SIZE[0] * DMD_SCALE,
                   height=DMD_SIZE[1] * DMD_SCALE)

        del image

        gl.glScalef(DMD_SCALE / float(MASK_SIZE), DMD_SCALE / float(MASK_SIZE),
                    1.0)
        gl.glColor4f(1.0, 1.0, 1.0, 1.0)
        self.mask_texture.blit_tiled(x=0,
                                     y=0,
                                     z=0,
                                     width=DMD_SIZE[0] * MASK_SIZE,
                                     height=DMD_SIZE[1] * MASK_SIZE)
コード例 #3
0
ファイル: label.py プロジェクト: bitcraft/pyglet
    def render(self, rect):
        image = self.image
        if image is None:
            return

        ir = util.Rect(image.x, image.y, image.width, image.height)
        if ir.clippedBy(rect):
            rect = ir.intersect(rect)
            if rect is None:
                return

            image = image.get_region(rect.x, rect.y, rect.width, rect.height)

        attrib = 0
        if not self.isEnabled():
            attrib = GL_CURRENT_BIT
        elif self.blend_color and self.color is not None:
            attrib = GL_CURRENT_BIT
        if self.is_blended:
            attrib |= GL_ENABLE_BIT

        if attrib:
            glPushAttrib(attrib)

        if attrib & GL_ENABLE_BIT:
            # blend with background
            glEnable(GL_BLEND)

        if attrib & GL_CURRENT_BIT:
            if not self.isEnabled():
                # blend with gray colour to wash out
                glColor4f(.7, .7, .7, 1.)
            else:
                glColor4f(*self.color)

        # TODO: alignment

        # blit() handles enabling GL_TEXTURE_2D and binding
        image.blit(rect.x, rect.y, 0)

        if attrib:
            glPopAttrib()
コード例 #4
0
    def render(self, rect):
        image = self.image
        if image is None:
            return

        ir = util.Rect(image.x, image.y, image.width, image.height)
        if ir.clippedBy(rect):
            rect = ir.intersect(rect)
            if rect is None: return

            image = image.get_region(rect.x, rect.y, rect.width, rect.height)

        attrib = 0
        if not self.isEnabled():
            attrib = GL_CURRENT_BIT
        elif self.blend_color and self.color is not None:
            attrib = GL_CURRENT_BIT
        if self.is_blended:
            attrib |= GL_ENABLE_BIT

        if attrib:
            glPushAttrib(attrib)

        if attrib & GL_ENABLE_BIT:
            # blend with background
            glEnable(GL_BLEND)

        if attrib & GL_CURRENT_BIT:
            if not self.isEnabled():
                # blend with gray colour to wash out
                glColor4f(.7, .7, .7, 1.)
            else:
                glColor4f(*self.color)

        # XXX alignment

        # blit() handles enabling GL_TEXTURE_2D and binding
        image.blit(rect.x, rect.y, 0)

        if attrib:
            glPopAttrib()
コード例 #5
0
ファイル: Game.py プロジェクト: christopherwhaas/MineCAD
 def drawCurrentBlock(self):
     if self.player.block == 1:
         image = pyglet.image.load(os.path.join(settings.texturesFolder,'Blue.png'))
         x,y = image.width, image.height
         image.blit(self.width-100,0)
     if self.player.block == 2:
         image = pyglet.image.load(os.path.join(settings.texturesFolder,'Red.png'))
         x,y = image.width, image.height
         image.blit(self.width-100,0)
     if self.player.block == 3:
         image = pyglet.image.load(os.path.join(settings.texturesFolder,'Purple.png'))
         x,y = image.width, image.height
         image.blit(self.width-100,0)
     if self.player.block == 4:
         image = pyglet.image.load(os.path.join(settings.texturesFolder,'Orange.png'))
         x,y = image.width, image.height
         image.blit(self.width-100,0)
コード例 #6
0
 def on_draw(self):
     image.blit(x=0, y=0)
     self.DrawGLScene()
コード例 #7
0
 def update(self,dt):
     image.blit(x=0, y=0)
     self.DrawGLScene()
コード例 #8
0
ファイル: slideshow.py プロジェクト: robmcmullen/dinoteeth
    def blit(cls, image, x, y):
#        with cls.lock:
#            image.blit(x, y)
        image.blit(x, y)