Ejemplo n.º 1
0
 def render(self, x, y, w=None, h=None, z=0.0, opacity=1.0):
     if w is None:
         w = self.w
     if h is None:
         h = self.h
     self.bind()
     fs_emu_texturing(True)
     if self.gl_type == gl.GL_RGBA or opacity < 1.0:
         fs_emu_blending(True)
     else:
         fs_emu_blending(False)
     gl.glBegin(gl.GL_QUADS)
     if opacity < 1.0:
         gl.glColor4f(opacity, opacity, opacity, opacity)
     else:
         gl.glColor3f(1.0, 1.0, 1.0)
     gl.glTexCoord(0.0, 1.0)
     gl.glVertex3f(x, y, z)
     gl.glTexCoord(1.0, 1.0)
     gl.glVertex3f(x + w, y, z)
     gl.glTexCoord(1.0, 0.0)
     gl.glVertex3f(x + w, y + h, z)
     gl.glTexCoord(0.0, 0.0)
     gl.glVertex3f(x, y + h, z)
     gl.glEnd()
Ejemplo n.º 2
0
 def render(self, x, y, w=None, h=None, z=0.0, opacity=1.0):
     if w is None:
         w = self.w
     if h is None:
         h = self.h
     self.bind()
     fs_emu_texturing(True)
     if self.gl_type == gl.GL_RGBA or opacity < 1.0:
         fs_emu_blending(True)
     else:
         fs_emu_blending(False)
     gl.glBegin(gl.GL_QUADS)
     if opacity < 1.0:
         gl.glColor4f(opacity, opacity, opacity, opacity)
     else:
         gl.glColor3f(1.0, 1.0, 1.0)
     gl.glTexCoord(0.0, 1.0)
     gl.glVertex3f(x, y, z)
     gl.glTexCoord(1.0, 1.0)
     gl.glVertex3f(x + w, y, z)
     gl.glTexCoord(1.0, 0.0)
     gl.glVertex3f(x + w, y + h, z)
     gl.glTexCoord(0.0, 0.0)
     gl.glVertex3f(x, y + h, z)
     gl.glEnd()
Ejemplo n.º 3
0
def texture_rectangle(x, y, w, h, z=0.0, s1=0.0, s2=1.0, t1=1.0, t2=0.0):
    gl.glBegin(gl.GL_QUADS)
    gl.glTexCoord(s1, t1)
    gl.glVertex3f(x, y, z)
    gl.glTexCoord(s2, t1)
    gl.glVertex3f(x + w, y, z)
    gl.glTexCoord(s2, t2)
    gl.glVertex3f(x + w, y + h, z)
    gl.glTexCoord(s1, t2)
    gl.glVertex3f(x, y + h, z)
    gl.glEnd()
Ejemplo n.º 4
0
def texture_rectangle(x, y, w, h, z=0.0, s1=0.0, s2=1.0, t1=1.0, t2=0.0):
    gl.glBegin(gl.GL_QUADS)
    gl.glTexCoord(s1, t1)
    gl.glVertex3f(x, y, z)
    gl.glTexCoord(s2, t1)
    gl.glVertex3f(x + w, y, z)
    gl.glTexCoord(s2, t2)
    gl.glVertex3f(x + w, y + h, z)
    gl.glTexCoord(s1, t2)
    gl.glVertex3f(x, y + h, z)
    gl.glEnd()
Ejemplo n.º 5
0
 def render_background(self):
     if self.background_texture:
         gl.glBindTexture(gl.GL_TEXTURE_2D, self.background_texture)
         gl.glColor3f(1.0, 1.0, 1.0)
     else:
         gl.glBindTexture(gl.GL_TEXTURE_2D, 0)
         # r, g, b a = self.background_color
         gl.glColor4f(*self.background_color)
     gl.glBegin(gl.GL_QUADS)
     bgx, bgy = self.background_texture_offset
     gl.glTexCoord(bgx + 0.0, bgy + 1.0)
     gl.glVertex2f(0, 0)
     gl.glTexCoord(bgx + 1.0, bgy + 1.0)
     gl.glVertex2f(self.width, 0)
     gl.glTexCoord(bgx + 1.0, bgy + 0.0)
     gl.glVertex2f(self.width, self.height)
     gl.glTexCoord(bgx + 0.0, bgy + 0.0)
     gl.glVertex2f(0, self.height)
     gl.glEnd()
Ejemplo n.º 6
0
def render_item_gloss(alpha, ratio=1.0, brightness=1.0, area=None):
    if State.get().max_ratio:
        ratio = min(State.get().max_ratio, ratio)
    if State.get().force_portrait and ratio > 1.0:
        ratio = 1.0 / ratio
    ba = brightness * alpha
    gl.glColor4f(ba, ba, ba, alpha)
    fs_emu_blending(True)
    fs_emu_texturing(True)
    creating_list = DisplayLists.call_or_create("gloss", ratio)
    if not creating_list:
        return
    gl.glPolygonOffset(0.0, -4.0)
    gl.glEnable(gl.GL_POLYGON_OFFSET_FILL)
    gl.glDepthMask(False)
    # glBindTexture(GL_TEXTURE_2D, Texture.gloss)
    texture = Texture.gloss
    texture.bind()
    area = area or 0.8
    height = math.sqrt(area / ratio)
    width = ratio * height
    gl.glTranslatef(-width / 2.0, -0.5, 0.0)
    gl.glBegin(gl.GL_QUADS)
    gl.glTexCoord(0.0, 1.0)
    gl.glVertex3f(0.0, 0.0, 0.0)
    gl.glTexCoord(1.0, 1.0)
    gl.glVertex3f(width, 0.0, 0.0)
    gl.glTexCoord(1.0, 0.0)
    gl.glVertex3f(width, height, 0.0)
    gl.glTexCoord(0.0, 0.0)
    gl.glVertex3f(0.0, height, 0.0)
    gl.glEnd()
    gl.glPolygonOffset(0.0, 0.0)
    gl.glDisable(gl.GL_POLYGON_OFFSET_FILL)
    gl.glDepthMask(True)
    # fs_emu_blending(False)
    if creating_list:
        gl.glEndList()
Ejemplo n.º 7
0
def render_item_shadow(ratio=1.0, brightness=1.0, area=None):
    if State.get().max_ratio:
        ratio = min(State.get().max_ratio, ratio)
    if State.get().force_portrait and ratio > 1.0:
        ratio = 1.0 / ratio
    gl.glColor4f(brightness, brightness, brightness, brightness)
    creating_list = DisplayLists.call_or_create("shadow", ratio, area)
    if not creating_list:
        return
    gl.glTranslatef(0.0, -0.5, 0.0)
    area = area or 0.8
    height = math.sqrt(area / ratio)
    width = ratio * height
    wh = width / 2
    t1 = 120 / 512
    t2 = (512 - 120) / 512
    gl.glBegin(gl.GL_QUADS)
    # left
    gl.glTexCoord(0.0, t2)
    gl.glVertex3f(-wh - 0.1, 0.02, 0.0)
    gl.glTexCoord(t1, t2)
    gl.glVertex3f(-wh + 0.02, 0.02, 0.0)
    gl.glTexCoord(t1, t1)
    gl.glVertex3f(-wh + 0.02, height - 0.02, 0.0)
    gl.glTexCoord(0.0, t1)
    gl.glVertex3f(-wh - 0.1, height - 0.02, 0.0)
    # top left
    gl.glTexCoord(0.0, t1)
    gl.glVertex3f(-wh - 0.1, height - 0.02, 0.0)
    gl.glTexCoord(t1, t1)
    gl.glVertex3f(-wh + 0.02, height - 0.02, 0.0)
    gl.glTexCoord(t1, 0.0)
    gl.glVertex3f(-wh + 0.02, height + 0.1, 0.0)
    gl.glTexCoord(0.0, 0.0)
    gl.glVertex3f(-wh - 0.1, height + 0.1, 0.0)
    # top
    gl.glTexCoord(t1, t1)
    gl.glVertex3f(-wh + 0.02, height - 0.02, 0.0)
    gl.glTexCoord(t2, t1)
    gl.glVertex3f(wh - 0.02, height - 0.02, 0.0)
    gl.glTexCoord(t2, 0.0)
    gl.glVertex3f(wh - 0.02, height + 0.1, 0.0)
    gl.glTexCoord(t1, 0.0)
    gl.glVertex3f(-wh + 0.02, height + 0.1, 0.0)
    # top right
    gl.glTexCoord(t2, t1)
    gl.glVertex3f(wh - 0.02, height - 0.02, 0.0)
    gl.glTexCoord(1.0, t1)
    gl.glVertex3f(wh + 0.1, height - 0.02, 0.0)
    gl.glTexCoord(1.0, 0.0)
    gl.glVertex3f(wh + 0.1, height + 0.1, 0.0)
    gl.glTexCoord(t2, 0.0)
    gl.glVertex3f(wh - 0.02, height + 0.1, 0.0)
    # right
    gl.glTexCoord(t2, t2)
    gl.glVertex3f(wh - 0.02, 0.02, 0.0)
    gl.glTexCoord(1.0, t2)
    gl.glVertex3f(wh + 0.1, 0.02, 0.0)
    gl.glTexCoord(1.0, t1)
    gl.glVertex3f(wh + 0.1, height - 0.02, 0.0)
    gl.glTexCoord(t2, t1)
    gl.glVertex3f(wh - 0.02, height - 0.02, 0.0)
    # bottom right
    gl.glTexCoord(t2, 1.0)
    gl.glVertex3f(wh - 0.02, -0.1, 0.0)
    gl.glTexCoord(1.0, 1.0)
    gl.glVertex3f(wh + 0.1, -0.1, 0.0)
    gl.glTexCoord(1.0, t2)
    gl.glVertex3f(wh + 0.1, 0.02, 0.0)
    gl.glTexCoord(t2, t2)
    gl.glVertex3f(wh - 0.02, 0.02, 0.0)
    # bottom
    gl.glTexCoord(t1, 1.0)
    gl.glVertex3f(-wh + 0.02, -0.1, 0.0)
    gl.glTexCoord(t2, 1.0)
    gl.glVertex3f(wh - 0.02, -0.1, 0.0)
    gl.glTexCoord(t2, t2)
    gl.glVertex3f(wh - 0.02, 0.02, 0.0)
    gl.glTexCoord(t1, t2)
    gl.glVertex3f(-wh + 0.02, 0.02, 0.0)
    # bottom left
    gl.glTexCoord(0.0, 1.0)
    gl.glVertex3f(-wh - 0.1, -0.1, 0.0)
    gl.glTexCoord(t1, 1.0)
    gl.glVertex3f(-wh + 0.02, -0.1, 0.0)
    gl.glTexCoord(t1, t2)
    gl.glVertex3f(-wh + 0.02, 0.02, 0.0)
    gl.glTexCoord(0.0, t2)
    gl.glVertex3f(-wh - 0.1, 0.02, 0.0)
    gl.glEnd()
    # end list
    if creating_list:
        gl.glEndList()