Example #1
0
    def draw(self):
        t1 = time.time()
        glClearColor(0.0, 0.0, 0.0, 0.0)
        glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()
        horizonY = 1 * 2.2 - .6 + .5
        GLU.gluLookAt(self.eyeX.x, horizonY, 8.0, self.lookX.x, horizonY, 0.0,
                      0.0, 1.0, 0.0)

        glEnable(GL.GL_TEXTURE_2D)

        if 0:
            with pushMatrix():
                glColor3f(1, 0, 0)
                glTranslatef(*self.ball)
                glScalef(.2, .2, 1)
                imageCard("sample.jpg")

        with pushMatrix():
            with mode(disable=[GL.GL_LIGHTING]):
                for card in self.cards:
                    card.draw(self.eyeX.x, horizonY, self.cardList)

        glFlush()
        pygame.display.flip()
Example #2
0
    def draw(self):
        t1 = time.time()
        glClearColor(0.0, 0.0, 0.0, 0.0)
        glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        glLoadIdentity ()
        horizonY = 1 * 2.2 - .6 + .5
        GLU.gluLookAt(self.eyeX.x, horizonY, 8.0,
                      self.lookX.x, horizonY, 0.0,
                      0.0, 1.0, 0.0)

        glEnable(GL.GL_TEXTURE_2D)

        if 0:
            with pushMatrix():
                glColor3f(1,0,0)
                glTranslatef(*self.ball)
                glScalef(.2, .2, 1)
                imageCard("sample.jpg")

        with pushMatrix():
            with mode(disable=[GL.GL_LIGHTING]):
                for card in self.cards:
                    card.draw(self.eyeX.x, horizonY, self.cardList)

        glFlush()
        pygame.display.flip()
Example #3
0
    def draw(self, eyeX, horizonY, cardList):
        """draw the card in place, using small/large image data as needed """

        with pushMatrix():
            pos = num.array(self.center)
            pos[2] += self.z.x
            if self.zoom:
                full = [eyeX, horizonY, 6.3]
                pos = lerp(pos, full, self.zoom)
            glTranslatef(*pos)

            layers = [('thumb', 1, self.thumbImage.getData('thumb'))]
            if self.zoom:
                data = self.thumbImage.getData('full')
                if data is not None:
                    layers.append(('full', 1, data))
                    # once opacity is fadable, and it's at 1, then we
                    # can remove the thumb layer from the list.

                    layers.reverse() # fix opengl draw order so hires is on top

                    

            for size, opacity, imgData in layers:
                if imgData is None:
                    # need to unset tx here!
                    glCallList(cardList)
                    # or draw a blank border, maybe some load status
                    # indication
                else:
                    (w,h), textureData = imgData
                    glBindTexture(GL.GL_TEXTURE_2D, 0)
                    glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB,
                                 w,
                                 h,
                                 0,
                                 GL.GL_RGB, GL.GL_UNSIGNED_BYTE, textureData)
                    glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER,
                                    GL.GL_LINEAR)
                    glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,
                                    GL.GL_LINEAR)

                    # card facing +Z from -1<x<1 -1<y<1
                    glCallList(cardList)
Example #4
0
    def draw(self, eyeX, horizonY, cardList):
        """draw the card in place, using small/large image data as needed """

        with pushMatrix():
            pos = num.array(self.center)
            pos[2] += self.z.x
            if self.zoom:
                full = [eyeX, horizonY, 6.3]
                pos = lerp(pos, full, self.zoom)
            glTranslatef(*pos)

            layers = [('thumb', 1, self.thumbImage.getData('thumb'))]
            if self.zoom:
                data = self.thumbImage.getData('full')
                if data is not None:
                    layers.append(('full', 1, data))
                    # once opacity is fadable, and it's at 1, then we
                    # can remove the thumb layer from the list.

                    layers.reverse(
                    )  # fix opengl draw order so hires is on top

            for size, opacity, imgData in layers:
                if imgData is None:
                    # need to unset tx here!
                    glCallList(cardList)
                    # or draw a blank border, maybe some load status
                    # indication
                else:
                    (w, h), textureData = imgData
                    glBindTexture(GL.GL_TEXTURE_2D, 0)
                    glTexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGB, w, h, 0,
                                 GL.GL_RGB, GL.GL_UNSIGNED_BYTE, textureData)
                    glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER,
                                    GL.GL_LINEAR)
                    glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,
                                    GL.GL_LINEAR)

                    # card facing +Z from -1<x<1 -1<y<1
                    glCallList(cardList)