def render_global_fade(): t = State.get().time if State.get().fade_end >= t >= State.get().fade_start: a = (t - State.get().fade_start) / ( State.get().fade_end - State.get().fade_start) if a < 0.0: a = 0.0 elif a > 1.0: a = 1.0 Render.get().hd_perspective() gl.glPushMatrix() gl.glTranslatef(0.0, 0.0, 0.99999) fs_emu_blending(True) fs_emu_texturing(True) if State.get().fade_splash: Texture.splash.render( (1920 - Texture.splash.w) // 2, (1080 - Texture.splash.h) // 2, Texture.splash.w, Texture.splash.h, opacity=(1.0 - a)) c = [0, 0, 0, (1.0 - a)] # for i in range(4): # c[i] = State.get().fade_from[i] + \ # (State.get().fade_to[i] - State.get().fade_from[i]) * a # * (a) render_fade(*c) gl.glPopMatrix() Render.get().dirty = True
def render_item_shadows(itemdata, front=False, back=True): Render.get().standard_perspective() # glEnable(GL_STENCIL_TEST) # glStencilFunc(GL_EQUAL, 1, 1) if front: gl.glPolygonOffset(0.0, -4.0) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) elif back: gl.glPolygonOffset(0.0, 4.0) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) gl.glDepthMask(False) fs_emu_blending(True) fs_emu_texturing(True) gl.glBindTexture(gl.GL_TEXTURE_2D, Texture.shadow2) for type_, menu, item_index, pos, rotation, scale, ratio, brightness, \ area in reversed(itemdata): gl.glPushMatrix() gl.glTranslate(*pos) gl.glRotate(rotation, 0.0, 1.0, 0.0) gl.glScalef(scale, scale, 1.0) render_item_shadow(ratio=ratio, brightness=brightness, area=area) gl.glScalef(1.0, -1.0, 1.0) gl.glTranslatef(0.0, 0.5, 0.0) # render_item_shadow(ratio=ratio, # brightness=brightness * 0.33, area=area) render_item_shadow(ratio=ratio, brightness=brightness, area=area) gl.glPopMatrix() gl.glPolygonOffset(0.0, 0.0) gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) gl.glDepthMask(True)
def render_item_shadows(itemdata, front=False, back=True): Render.get().standard_perspective() # glEnable(GL_STENCIL_TEST) # glStencilFunc(GL_EQUAL, 1, 1) if front: gl.glPolygonOffset(0.0, -4.0) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) elif back: gl.glPolygonOffset(0.0, 4.0) gl.glEnable(gl.GL_POLYGON_OFFSET_FILL) gl.glDepthMask(False) fs_emu_blending(True) fs_emu_texturing(True) gl.glBindTexture(gl.GL_TEXTURE_2D, Texture.shadow2) for type_, menu, item_index, pos, rotation, scale, ratio, brightness, \ area in reversed(itemdata): gl.glPushMatrix() gl.glTranslate(*pos) gl.glRotate(rotation, 0.0, 1.0, 0.0) gl.glScalef(scale, scale, 1.0) render_item_shadow(ratio=ratio, brightness=brightness, area=area) gl.glScalef(1.0, -1.0, 1.0) gl.glTranslatef(0.0, 0.5, 0.0) # render_item_shadow(ratio=ratio, # brightness=brightness * 0.33, area=area) render_item_shadow(ratio=ratio, brightness=brightness, area=area) gl.glPopMatrix() gl.glPolygonOffset(0.0, 0.0) gl.glDisable(gl.GL_POLYGON_OFFSET_FILL) gl.glDepthMask(True)
def render(self): Render.get().ortho_perspective() gl.glDisable(gl.GL_DEPTH_TEST) fs_emu_blending(True) gl.glPushMatrix() gl.glTranslatef(-self.width / 2, -self.height / 2, 0.0) self.render_background() self.render_content() gl.glPopMatrix() gl.glEnable(gl.GL_DEPTH_TEST) pass
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()
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()