def render_one(cls, notification): notification.show() w = 500 h = 100 x = 1920 - w y = cls.y z = 0.9 fs_emu_texturing(False) fs_emu_blending(True) gl.glBegin(gl.GL_QUADS) gl.glColor(1.0, 1.0, 0.5, 0.8) gl.glVertex3f(x, y, z) gl.glVertex3f(x + w, y, z) gl.glVertex3f(x + w, y + h, z) gl.glVertex3f(x, y + h, z) gl.glEnd() lines = notification.text.split("\n") y += h - 23 for line in lines: tw, th = Render.get().measure_text(line, cls.font) y -= th Render.get().text(line, cls.font, x + 23, y, color=(0.2, 0.2, 0.0, 1.0)) y -= 2 cls.y += h + 15
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()
def render_one(cls, notification): notification.show() w = 500 h = 100 x = START_X y = cls.y z = 0.9 y -= h gl.glDisable(gl.GL_DEPTH_TEST) fs_emu_texturing(False) fs_emu_blending(True) gl.glBegin(gl.GL_QUADS) gl.glColor(1.0, 1.0, 0.5, 0.8) gl.glVertex3f(x, y, z) gl.glVertex3f(x + w, y, z) gl.glVertex3f(x + w, y + h, z) gl.glVertex3f(x, y + h, z) gl.glEnd() lines = notification.text.split("\n") y += h - 23 for line in lines: tw, th = Render.get().measure_text(line, cls.font) y -= th Render.get().text( line, cls.font, x + 23, y, color=(0.2, 0.2, 0.0, 1.0) ) y -= 2 # cls.y += h + 15 cls.y -= h + 20 gl.glEnable(gl.GL_DEPTH_TEST)
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()
def render(self): z = -0.999 fs_emu_texturing(False) fs_emu_blending(False) gl.glBegin(gl.GL_QUADS) gl.glColor3f(0.0, 0.0, 0.0) # glVertex3f(0, 365, z) # glVertex3f(1270, 365, z) gl.glVertex3f(0, 400, z) gl.glVertex3f(1270, 400, z) gl.glColor3f(0.25, 0.25, 0.25) gl.glVertex3f(1270, 1080 - 60, z) gl.glVertex3f(0, 1080 - 60, z) gl.glEnd()
def render_debug_square_2(): global debug_x_2 Render.get().hd_perspective() fs_emu_texturing(False) gl.glBegin(gl.GL_QUADS) gl.glColor3f(0.2, 0.2, 0.2) x = debug_x_2 debug_x_2 += 1 if debug_x_2 >= 1920: debug_x_2 = 0 y = 989 + 5 z = 0.99 gl.glVertex3f(x, y, z) gl.glVertex3f(x + 20, y, z) gl.glVertex3f(x + 20, y + 10, z) gl.glVertex3f(x, y + 10, z) gl.glEnd() fs_emu_texturing(True)
def render_debug_square(): global debug_x Render.get().hd_perspective() fs_emu_texturing(False) gl.glBegin(gl.GL_QUADS) gl.glColor3f(1.0, 1.0, 1.0) x = debug_x debug_x += 1 if debug_x >= 1920: debug_x = 0 y = 989 z = 0.99 gl.glVertex3f(x, y, z) gl.glVertex3f(x + 20, y, z) gl.glVertex3f(x + 20, y + 20, z) gl.glVertex3f(x, y + 20, z) gl.glEnd() fs_emu_texturing(True)
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_wall(): # brightness=1.0): # glClearColor(0.1, 0.1, 0.1, 1.0) # glClear(GL_DEPTH_BUFFER_BIT); Render.get().hd_perspective() # fs_emu_ortho(); # fs_emu_blending(FALSE); # fs_emu_texturing(FALSE); z = -0.999 # glPushMatrix() # glTranslate(0.0, 0.0, 1.0) # transition y-coordinate between floor and wall split = 361 fs_emu_blending(False) fs_emu_texturing(False) gl.glBegin(gl.GL_QUADS) gl.glColor3f(39.0 / 255.0, 44.0 / 255.0, 51.0 / 255.0) gl.glVertex3f(0, split, z) gl.glVertex3f(1920, split, z) color = 0 gl.glColor3f(color, color, color) gl.glVertex3f(1920, 1020, z) gl.glVertex3f(0, 1020, z) gl.glVertex3f(0, 1020, z) gl.glVertex3f(1920, 1020, z) gl.glVertex3f(1920, 1080, z) gl.glVertex3f(0, 1080, z) color = 0 gl.glColor3f(color, color, color) gl.glVertex3f(0, 0, z) gl.glVertex3f(1920, 0, z) gl.glColor3f(20.0 / 255.0, 22.0 / 255.0, 26.0 / 255.0) gl.glVertex3f(1920, split, z) gl.glVertex3f(0, split, z) gl.glEnd()
def render(self, transition=1.0): Render.get().hd_perspective() # w = 560 # h = 92 # x = 1920 - w * transition # y = 1080 - 60 - h # y = 1080 - 60 - h - 44 # z = -0.9 item_top = 1080 - 90 item_left = 1920 - 560 + 40 item_left += Texture.sidebar_background_shadow.w * (1.0 - transition) gl.glPushMatrix() gl.glTranslate(0.0, 0.0, 0.7) # glTranslated((1.0 - transition) * g_tex_sidebar_background->width, # 0, 0) # fs_emu_set_texture(g_tex_sidebar_background) # fs_emu_render_texture_with_size(g_tex_sidebar_background, # 1920 - g_tex_sidebar_background->width, # 0, g_tex_sidebar_background->width, # g_tex_sidebar_background->height) # fs_emu_render_sidebar() fs_emu_blending(True) fs_emu_texturing(True) gl.glDepthMask(False) Texture.sidebar_background_shadow.render( 1920 - Texture.sidebar_background_shadow.w * transition, 0, Texture.sidebar_background_shadow.w, Texture.sidebar_background_shadow.h) gl.glDepthMask(True) gl.glPopMatrix() # x = x + 70 # w = w - 70 x = item_left y = item_top - 60 w = 560 - 40 - 40 h = 60 for i, item in enumerate(self.items): if item.group: if i > 0: # skip one half row before group heading y -= h / 2 selected = i == self.index and State.get().navigatable == self z = 0.71 fs_emu_texturing(False) if selected: fg_color = [1.0, 1.0, 1.0, 1.0] gl.glBegin(gl.GL_QUADS) gl.glColor3f(0.00, 0x99 / 0xff, 0xcc / 0xff) gl.glVertex3f(x, y + 4, z) gl.glVertex3f(x + w, y + 4, z) gl.glVertex3f(x + w, y + h - 4, z) gl.glVertex3f(x, y + h - 4, z) # glColor3f(0.6, 0.6, 0.6) # glVertex3f(x, y + 4, z) # glVertex3f(x + w, y + 4, z) # glVertex3f(x + w, y + h, z) # glVertex3f(x, y + h, z) gl.glEnd() else: fg_color = [1.0, 1.0, 1.0, 1.0] # glBegin(GL_QUADS) # glColor3f(0.4, 0.4, 0.4) # glVertex3f(x, y, z) # glVertex3f(x + w, y, z) # glVertex3f(x + w, y + 4, z) # glVertex3f(x, y + 4, z) # glEnd() # fs_emu_texturing(True) if i > 0: fg_color[3] *= 0.35 text = item.title # FIXME: REMOVE # fs_emu_blending(False) # fs_emu_blending(True) gl.glDisable(gl.GL_DEPTH_TEST) if item.group: BitmapFont.menu_font.render(text, x + 20, y + 14, r=0.0, g=0x99 / 0xff, b=0xcc / 0xff) else: BitmapFont.menu_font.render(text, x + 20, y + 14) gl.glEnable(gl.GL_DEPTH_TEST) # text = item.title.upper() # tw, th = Render.get().text(text, Font.main_path_font, # x + 40, y + 43, color=fg_color) # text = item.subtitle.upper() # fg_color[3] = fg_color[3] * 0.4 # text = item.title.upper() # tw, th = Render.get().text(text, Font.list_subtitle_font, # x + 40, y + 18, color=fg_color) y -= h
def render(self, transition=1.0): Render.get().hd_perspective() # w = 560 # h = 92 # x = 1920 - w * transition # y = 1080 - 60 - h # y = 1080 - 60 - h - 44 # z = -0.9 item_top = 1080 - 90 item_left = 1920 - 560 + 40 item_left += Texture.sidebar_background_shadow.w * ( 1.0 - transition) gl.glPushMatrix() gl.glTranslate(0.0, 0.0, 0.7) # glTranslated((1.0 - transition) * g_tex_sidebar_background->width, # 0, 0) # fs_emu_set_texture(g_tex_sidebar_background) # fs_emu_render_texture_with_size(g_tex_sidebar_background, # 1920 - g_tex_sidebar_background->width, # 0, g_tex_sidebar_background->width, # g_tex_sidebar_background->height) # fs_emu_render_sidebar() fs_emu_blending(True) fs_emu_texturing(True) gl.glDepthMask(False) Texture.sidebar_background_shadow.render( 1920 - Texture.sidebar_background_shadow.w * transition, 0, Texture.sidebar_background_shadow.w, Texture.sidebar_background_shadow.h) gl.glDepthMask(True) gl.glPopMatrix() # x = x + 70 # w = w - 70 x = item_left y = item_top - 60 w = 560 - 40 - 40 h = 60 for i, item in enumerate(self.items): if item.group: if i > 0: # skip one half row before group heading y -= h / 2 selected = i == self.index and State.get().navigatable == self z = 0.71 fs_emu_texturing(False) if selected: fg_color = [1.0, 1.0, 1.0, 1.0] gl.glBegin(gl.GL_QUADS) gl.glColor3f(0.00, 0x99 / 0xff, 0xcc / 0xff) gl.glVertex3f(x, y + 4, z) gl.glVertex3f(x + w, y + 4, z) gl.glVertex3f(x + w, y + h - 4, z) gl.glVertex3f(x, y + h - 4, z) # glColor3f(0.6, 0.6, 0.6) # glVertex3f(x, y + 4, z) # glVertex3f(x + w, y + 4, z) # glVertex3f(x + w, y + h, z) # glVertex3f(x, y + h, z) gl.glEnd() else: fg_color = [1.0, 1.0, 1.0, 1.0] # glBegin(GL_QUADS) # glColor3f(0.4, 0.4, 0.4) # glVertex3f(x, y, z) # glVertex3f(x + w, y, z) # glVertex3f(x + w, y + 4, z) # glVertex3f(x, y + 4, z) # glEnd() # fs_emu_texturing(True) if i > 0: fg_color[3] *= 0.35 text = item.title # FIXME: REMOVE # fs_emu_blending(False) # fs_emu_blending(True) gl.glDisable(gl.GL_DEPTH_TEST) if item.group: BitmapFont.menu_font.render( text, x + 20, y + 14, r=0.0, g=0x99 / 0xff, b=0xcc / 0xff) else: BitmapFont.menu_font.render(text, x + 20, y + 14) gl.glEnable(gl.GL_DEPTH_TEST) # text = item.title.upper() # tw, th = Render.get().text(text, Font.main_path_font, # x + 40, y + 43, color=fg_color) # text = item.subtitle.upper() # fg_color[3] = fg_color[3] * 0.4 # text = item.title.upper() # tw, th = Render.get().text(text, Font.list_subtitle_font, # x + 40, y + 18, color=fg_color) y -= h
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()
def rectangle(x, y, w, h, z=0.0): # gl.glBegin(gl.GL_QUADS) gl.glVertex3f(x, y, z) gl.glVertex3f(x + w, y, z) gl.glVertex3f(x + w, y + h, z) gl.glVertex3f(x, y + h, z)
def render_wall(): # brightness=1.0): # glClearColor(0.1, 0.1, 0.1, 1.0) # glClear(GL_DEPTH_BUFFER_BIT); Render.get().hd_perspective() # fs_emu_ortho(); # fs_emu_blending(FALSE); # fs_emu_texturing(FALSE); z = -0.999 # glPushMatrix() # glTranslate(0.0, 0.0, 1.0) # transition y-coordinate between floor and wall splt = 361 fs_emu_blending(False) fs_emu_texturing(False) gl.glBegin(gl.GL_QUADS) gl.glColor3f(39.0 / 255.0, 44.0 / 255.0, 51.0 / 255.0) gl.glVertex3f(0, splt, z) gl.glVertex3f(1920, splt, z) color = 0 gl.glColor3f(color, color, color) gl.glVertex3f(1920, 1020, z) gl.glVertex3f(0, 1020, z) gl.glVertex3f(0, 1020, z) gl.glVertex3f(1920, 1020, z) gl.glVertex3f(1920, 1080, z) gl.glVertex3f(0, 1080, z) color = 0 gl.glColor3f(color, color, color) gl.glVertex3f(0, 0, z) gl.glVertex3f(1920, 0, z) gl.glColor3f(20.0 / 255.0, 22.0 / 255.0, 26.0 / 255.0) gl.glVertex3f(1920, splt, z) gl.glVertex3f(0, splt, z) gl.glEnd()