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().hd_perspective() if self.throbber_start_time == 0: self.throbber_start_time = State.get().time dt = State.get().time - self.throbber_start_time # run animation with 15 fps self.throbber_progress = int(dt * 15) bg_fade = (State.get().time - State.get().dialog_time) / 0.5 if bg_fade > 1.0: bg_fade = 1.0 elif bg_fade < 0.0: bg_fade = 0.0 fs_emu_texturing(False) fs_emu_blending(True) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDepthMask(False) gl.glBegin(gl.GL_QUADS) gl.glColor4f(0.0, 0.0, 0.0, bg_fade) gl.glVertex2f(0, 0) gl.glVertex2f(1920, 0) gl.glVertex2f(1920, 1020) gl.glVertex2f(0, 1020) gl.glEnd() gl.glBegin(gl.GL_QUADS) gl.glColor4f(0.0, 0.0, 0.0, bg_fade * 0.5) gl.glVertex2f(0, 1020) gl.glVertex2f(1920, 1020) gl.glVertex2f(1920, 1080) gl.glVertex2f(0, 1080) gl.glEnd() # y = 0.0 # tw, th = Render.get().text("LAUNCHING GAME", self.title_font, # 0.0, y, w=32 / 9, h=self.height, # color=(1.0, 1.0, 1.0, 1.0), halign=0.0) # fs_emu_blending(True) # if bg_fade > 0.5: # self.throbber_opacity = (bg_fade - 0.5) / 0.5 # #self.throbber_opacity = bg_fade # self.render_throbber() # if bg_fade == 1.0: if State.get().time - State.get().dialog_time > 1.0: # gradually show over 1/4 second self.throbber_opacity = (State.get().time - State.get().dialog_time - 1.0) * 4 if self.throbber_opacity > 1.0: self.throbber_opacity = 1.0 self.render_throbber() gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthMask(True) # fs_emu_texturing(1) # fs_emu_blending(0) # print("Setting dirty..") Render.get().dirty = True
def render(self): Render.get().hd_perspective() if self.throbber_start_time == 0: self.throbber_start_time = State.get().time dt = State.get().time - self.throbber_start_time # run animation with 15 fps self.throbber_progress = int(dt * 15) bg_fade = (State.get().time - State.get().dialog_time) / 0.5 if bg_fade > 1.0: bg_fade = 1.0 elif bg_fade < 0.0: bg_fade = 0.0 fs_emu_texturing(False) fs_emu_blending(True) gl.glDisable(gl.GL_DEPTH_TEST) gl.glDepthMask(False) gl.glBegin(gl.GL_QUADS) gl.glColor4f(0.0, 0.0, 0.0, bg_fade) gl.glVertex2f(0, 0) gl.glVertex2f(1920, 0) gl.glVertex2f(1920, 1020) gl.glVertex2f(0, 1020) gl.glEnd() gl.glBegin(gl.GL_QUADS) gl.glColor4f(0.0, 0.0, 0.0, bg_fade * 0.5) gl.glVertex2f(0, 1020) gl.glVertex2f(1920, 1020) gl.glVertex2f(1920, 1080) gl.glVertex2f(0, 1080) gl.glEnd() # y = 0.0 # tw, th = Render.get().text("LAUNCHING GAME", self.title_font, # 0.0, y, w=32 / 9, h=self.height, # color=(1.0, 1.0, 1.0, 1.0), halign=0.0) # fs_emu_blending(True) # if bg_fade > 0.5: # self.throbber_opacity = (bg_fade - 0.5) / 0.5 # #self.throbber_opacity = bg_fade # self.render_throbber() # if bg_fade == 1.0: if State.get().time - State.get().dialog_time > 1.0: # gradually show over 1/4 second self.throbber_opacity = ( State.get().time - State.get().dialog_time - 1.0) * 4 if self.throbber_opacity > 1.0: self.throbber_opacity = 1.0 self.render_throbber() gl.glEnable(gl.GL_DEPTH_TEST) gl.glDepthMask(True) # fs_emu_texturing(1) # fs_emu_blending(0) # print("Setting dirty..") Render.get().dirty = 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(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 - 50 # item_left = 1920 - 560 + 40 dx = 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, ) if transition > 1.0: padding = 1920 Texture.sidebar_background.render( 1920 - Texture.sidebar_background_shadow.w * transition + Texture.sidebar_background_shadow.w, 0, 1920 + padding, Texture.sidebar_background.h, ) gl.glDepthMask(True) gl.glPopMatrix() y = SIDEBAR_START_Y for i, item in enumerate(self.items): if item.group: if i > 0: y -= GROUP_SPACING selected = i == self.index and State.get().navigatable == self # z = 0.71 fs_emu_texturing(False) gl.glDisable(gl.GL_DEPTH_TEST) 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 - 18, z) # gl.glVertex3f(x + w, y - 18, 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() fs_emu_blending(True) fs_emu_texturing(True) gl.glDepthMask(False) Texture.item_background.render(1920 - 540 + 13 + dx, y - 18) gl.glDepthMask(True) 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) if item.group: BitmapFont.menu_font.render( text, HEADING_TEXT_LEFT + dx, y + 14, r=0.0, g=0x99 / 0xFF, b=0xCC / 0xFF, ) x, _ = BitmapFont.menu_font.measure(text) x += HEADING_TEXT_LEFT + 12 fs_emu_blending(True) fs_emu_texturing(True) # gl.glDepthMask(False) Texture.heading_strip.render(x + dx, y + 14, 1920 - x, 32) else: BitmapFont.menu_font.render(text, ITEM_TEXT_LEFT + dx, 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 -= 54 # Gradually erase menu items when transitioning if transition > 1.0: gl.glDisable(gl.GL_DEPTH_TEST) # tr = (transition - 1.0) / 3.0 alpha = max(0.0, (transition - 1.0) / 2.0) Texture.sidebar_background.render( 1920 - Texture.sidebar_background_shadow.w * transition + 200, 0, 1920, Texture.sidebar_background.h, opacity=alpha, ) gl.glEnable(gl.GL_DEPTH_TEST)
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(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 - 50 # item_left = 1920 - 560 + 40 dx = 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, ) if transition > 1.0: padding = 1920 Texture.sidebar_background.render( 1920 - Texture.sidebar_background_shadow.w * transition + Texture.sidebar_background_shadow.w, 0, 1920 + padding, Texture.sidebar_background.h, ) gl.glDepthMask(True) gl.glPopMatrix() y = SIDEBAR_START_Y for i, item in enumerate(self.items): if item.group: if i > 0: y -= GROUP_SPACING selected = i == self.index and State.get().navigatable == self # z = 0.71 fs_emu_texturing(False) gl.glDisable(gl.GL_DEPTH_TEST) 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 - 18, z) # gl.glVertex3f(x + w, y - 18, 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() fs_emu_blending(True) fs_emu_texturing(True) gl.glDepthMask(False) Texture.item_background.render(1920 - 540 + 13 + dx, y - 18) gl.glDepthMask(True) 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) if item.group: BitmapFont.menu_font.render( text, HEADING_TEXT_LEFT + dx, y + 14, r=0.0, g=0x99 / 0xFF, b=0xCC / 0xFF, ) x, _ = BitmapFont.menu_font.measure(text) x += HEADING_TEXT_LEFT + 12 fs_emu_blending(True) fs_emu_texturing(True) # gl.glDepthMask(False) Texture.heading_strip.render(x + dx, y + 14, 1920 - x, 32) else: BitmapFont.menu_font.render(text, ITEM_TEXT_LEFT + dx, 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 -= 54 # Gradually erase menu items when transitioning if transition > 1.0: gl.glDisable(gl.GL_DEPTH_TEST) # tr = (transition - 1.0) / 3.0 alpha = max(0.0, (transition - 1.0) / 2.0) Texture.sidebar_background.render( 1920 - Texture.sidebar_background_shadow.w * transition + 200, 0, 1920, Texture.sidebar_background.h, opacity=alpha, ) gl.glEnable(gl.GL_DEPTH_TEST)