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)
示例#2
0
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)
示例#3
0
    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
示例#4
0
 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
示例#5
0
 def render_top_left(self, selected=False):
     gl.glDisable(gl.GL_DEPTH_TEST)
     fs_emu_blending(True)
     x = 20
     y = 14
     texture = Texture.logo_32
     texture.render(x, 1080 - y - texture.h, texture.w, texture.h)
     x += 32 + 20
     BitmapFont.title_font.render("FS-UAE", x, self.y + 14)
     tw, _ = BitmapFont.title_font.measure("FS-UAE")
     x += tw + 20
     BitmapFont.title_font.render("Arcade", x, self.y + 14, alpha=0.5)
     gl.glEnable(gl.GL_DEPTH_TEST)
示例#6
0
 def render_top_left(self, selected=False):
     # self.render_top_background(selected, style=TOP_ITEM_ARROW)
     MenuItem.render_top_left(self, selected=selected)
     gl.glDisable(gl.GL_DEPTH_TEST)
     fs_emu_blending(True)
     # if app.name == "fs-uae-arcade":
     x = 161
     # else:
     #     x = 138
     y = 14
     # if selected:
     # texture = Texture.top_logo_selected
     # else:
     texture = Texture.top_logo
     texture.render(x, 1080 - y - texture.h, texture.w, texture.h)
     # fs_emu_blending(False)
     gl.glEnable(gl.GL_DEPTH_TEST)
示例#7
0
 def render_func():
     render_screen()
     Render.get().ortho_perspective()
     fs_emu_blending(True)
     fs_emu_texturing(False)
     gl.glDisable(gl.GL_DEPTH_TEST)
     gl.glBegin(gl.GL_QUADS)
     gl.glColor4f(0.0, 0.0, 0.0, alpha)
     gl.glVertex2f(-10.0, -1.0)
     gl.glVertex2f(10.0, -1.0)
     gl.glVertex2f(10.0, 1.0)
     gl.glVertex2f(-10.0, 1.0)
     gl.glEnd()
     gl.glEnable(gl.GL_DEPTH_TEST)
     # fs_emu_blending(False)
     fs_emu_texturing(True)
     swap_buffers()
     Render.get().dirty = True
示例#8
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()
示例#9
0
    def render_transparent(self, data):
        last_menu = State.get().history[-2]
        last_menu.render_transparent(self.last_menu_data)

        if Transition.value < 1.0:
            opacity = 1.0 - Transition.value
            opacity *= 1.25
            if opacity > 1.0:
                opacity = 1.0
            Render.get().hd_perspective()
            gl.glDisable(gl.GL_DEPTH_TEST)
            fs_emu_texturing(False)
            fs_emu_blending(True)
            gl.glBegin(gl.GL_QUADS)
            gl.glColor4f(0.0, 0.0, 0.0, opacity)
            gl.glVertex2f(0.0, 0.0)
            gl.glVertex2f(1920.0, 0.0)
            gl.glVertex2f(1920.0, 1020.0)
            gl.glVertex2f(0.0, 1020.0)
            gl.glEnd()
            gl.glEnable(gl.GL_DEPTH_TEST)

        self.config_list.render(Transition.value)
示例#10
0
 def render_top_right(self, selected=False):
     state = State.get()
     mouse_state = state.mouse_item == self
     mouse_pressed_state = mouse_state and state.mouse_press_item == self
     self.render_top_background(
         selected, style=TOP_ITEM_LEFT, mouse_state=mouse_state,
         mouse_pressed_state=mouse_pressed_state)
     gl.glDisable(gl.GL_DEPTH_TEST)
     fs_emu_blending(True)
     if Settings.instance()["video_sync"] == "1":
         r = 1.0
         g = 1.0
         b = 1.0
         alpha = 1.0
     else:
         r = 1.0
         g = 1.0
         b = 1.0
         alpha = 0.33
     x = self.x + 20
     BitmapFont.title_font.render(self.title, x, self.y + 14,
                                  r=r, g=g, b=b, alpha=alpha)
     gl.glEnable(gl.GL_DEPTH_TEST)
示例#11
0
def init_lighting():
    gl.glLightModeli(gl.GL_LIGHT_MODEL_LOCAL_VIEWER, gl.GL_TRUE)
    gl.glLightModeli(gl.GL_LIGHT_MODEL_TWO_SIDE, gl.GL_FALSE)
    gl.glLightModeli(
        gl.GL_LIGHT_MODEL_COLOR_CONTROL, gl.GL_SEPARATE_SPECULAR_COLOR)

    light_position = (0.0, 0.0, 3.0, 1.0)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, light_position)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_SPECULAR, (0.0, 0.0, 0.0, 1.0))
    gl.glEnable(gl.GL_LIGHT0)

    gl.glLightfv(gl.GL_LIGHT1, gl.GL_DIFFUSE, (0.0, 0.0, 0.0, 1.0))
    gl.glLightfv(gl.GL_LIGHT1, gl.GL_SPECULAR, (1.0, 1.0, 1.0, 1.0))
    gl.glEnable(gl.GL_LIGHT1)

    gl.glLightfv(gl.GL_LIGHT2, gl.GL_DIFFUSE, (0.0, 0.0, 0.0, 1.0))
    gl.glLightfv(gl.GL_LIGHT2, gl.GL_SPECULAR, (0.5, 0.5, 0.5, 1.0))
    gl.glEnable(gl.GL_LIGHT2)

    gl.glMaterialfv(gl.GL_FRONT, gl.GL_AMBIENT, (0.1, 0.1, 0.1, 1.0))
    gl.glMaterialfv(gl.GL_FRONT, gl.GL_SHININESS, (10,))
示例#12
0
def _render_menu(menu, what=None, skip_center_item=False):
    if what is None:
        what = ["ITEMS", "SHADOWS"]
    # print "render menu with", len(menu), "items"
    position = menu.get_current_position()
    # selected = menu.get_selected_index()
    assert not skip_center_item

    # min_item = 0
    # max_item = len(menu) - 1
    num_items = len(menu)
    # i_position = min(max_item, int(round(position)))
    i_position = int(round(position))

    # print position, " (", selected, ")"
    # print "selected", selected

    # glEnable(GL_DEPTH_TEST)

    def get_item_position(ip_distance):
        inverse = ip_distance < 0
        ip_distance = abs(ip_distance)
        # y = 0.02 - 0.5
        # y = 0.243
        y = 0.293
        z = -3.1
        if ip_distance < 1.0:
            x = ip_distance * 0.8
            ip_rotation = -45.0 * ip_distance
            z = z + 0.6 - 0.6 * ip_distance
        else:
            # x = 0.8 + 0.15 * (ip_distance - 1.0)
            # x = 0.8 + 0.20 * (ip_distance - 1.0)
            x = 0.8 + 0.33 * (ip_distance - 1.0)
            ip_rotation = -45.0
        if inverse:
            return [-x, y, z], -ip_rotation
        else:
            return [x, y, z], ip_rotation

    def yield_render_item_sequence():
        if not skip_center_item:
            yield i_position
        # if MenuGameTransition.value == 0: #< 0.00001:
        # for i in range(9, 0, -1):
        for i in range(1, 10):
            # if (i_position - i) >= min_item:
            yield i_position - i
            # if (i_position + i) <= max_item:
            yield i_position + i

    def yield_image_file_sequence():
        for img in menu[i_position % num_items].get_image_files():
            yield img
        for i in range(1, 12):
            # if (i_position - i) >= min_item:
            #     for img in menu[i_position - i].get_image_files():
            #         yield img
            # if (i_position + i) <= max_item:
            #     for img in menu[i_position + i].get_image_files():
            #         yield img
            for img in menu[(i_position - i) % num_items].get_image_files():
                yield img
            for img in menu[(i_position + i) % num_items].get_image_files():
                yield img

    item_data = []
    if "ITEMS" in what:
        TextureManager.get().load_images(list(yield_image_file_sequence()))
        # TextureManager.get().load_textures(1)

        center_item = None
        light1_position = [-1.5, 0.2, -2.3, 1.0]
        light2_position = [-0.5, 2.5, -2.3, 1.0]
        # glDisable(GL_LIGHT2)

        if LIGHTING:
            gl.glEnable(gl.GL_LIGHTING)
            gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, light1_position)
            gl.glLightfv(gl.GL_LIGHT2, gl.GL_POSITION, light2_position)
            gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, (1.0, 1.0, 1.0, 1.0))
        gl.glColor3f(1.0, 1.0, 1.0)

        # gloss_list = []
        # reflections = []
        # glColor3f(1.0, 1.0, 1.0)

        fs_emu_texturing(True)
        fs_emu_blending(False)

        for item_index in list(yield_render_item_sequence()):

            if num_items < MIN_WRAPAROUND_ITEMS:
                if not (
                    0
                    <= item_index - (i_position // num_items * num_items)
                    < num_items
                ):
                    continue

            rel_index = item_index - position  # selected

            distance = abs(rel_index)
            # strength = 1.0

            gl.glPushMatrix()

            pos, rotation = get_item_position(rel_index)

            gl.glTranslate(*pos)
            scale = 1.0
            area = 0.9

            item = menu[item_index % num_items]
            height = math.sqrt(area / item.ratio)
            width = item.ratio * height

            if rel_index <= 0.0:
                spec = 0.8
            elif rel_index > 1.0:
                spec = 0.05
            else:
                spec = 0.8 - rel_index / 1.0 * 0.75
            if LIGHTING:
                gl.glMaterialfv(
                    gl.GL_FRONT, gl.GL_SPECULAR, (spec, spec, spec, 1.0)
                )

            gl.glRotate(rotation, 0.0, 1.0, 0.0)

            item.render(width, height)

            if not LIGHTING:
                if distance < 1.0:
                    gloss_alpha = 0.25 + distance * 0.25
                else:
                    gloss_alpha = 0.5
                render_item_gloss(gloss_alpha, ratio=item.ratio, area=area)
            gl.glPopMatrix()
            item_data.append(
                (
                    "ITEM",
                    menu,
                    item_index,
                    pos,
                    rotation,
                    scale,
                    item.ratio,
                    1.0,
                    area,
                )
            )

            # reflections.append((item, pos, rotation,
            # width, height, spec * 0.3))

        if not center_item:
            State.get().center_item = None

        if LIGHTING:
            light1_position[1] = -light1_position[1]
            light2_position[1] = -light2_position[1]
            gl.glLightfv(gl.GL_LIGHT1, gl.GL_POSITION, light1_position)
            gl.glLightfv(gl.GL_LIGHT2, gl.GL_POSITION, light2_position)
            # glLightfv(GL_LIGHT1, GL_POSITION, (-5.0, -1.5, 1.2, 1.0))
            # glLightfv(GL_LIGHT2, GL_POSITION, (-0.5, -5.0, 1.2, 1.0))
            gl.glMaterialfv(gl.GL_FRONT, gl.GL_DIFFUSE, (0.3, 0.3, 0.3, 0.0))

        # glColor3f(0.3, 0.3, 0.3)
        # for item, pos, rotation, width, height, spec in reflections:
        #     #if LIGHTING:
        #     #    glMaterialfv(GL_FRONT, GL_SPECULAR, (spec, spec, spec, 1.0))
        #     #else:
        #     #    glColor4f(0.33, 0.33, 0.33, 0.33)
        #     #    fs_emu_blending(True)
        #     glPushMatrix()
        #     glTranslate(*pos)
        #     glRotate(rotation, 0.0, 1.0, 0.0)
        #     item.render(width, height, reflection=True)
        #     glPopMatrix()

        if LIGHTING:
            gl.glDisable(gl.GL_LIGHTING)

    return item_data
示例#13
0
    def render(self, text, x, y, r=1.0, g=1.0, b=1.0, alpha=1.0):
        global text_cache
        if not text:
            return 0

        # find cached text entry, if any

        for i, item in enumerate(text_cache):
            if item["text"] == text and item["font"] == self:
                text_cache.pop(i)
                break
        else:
            item = None

        if item:
            fs_emu_blending(True)
            fs_emu_texturing(True)

            w = item["w"]
            h = item["h"]
            gl.glBindTexture(gl.GL_TEXTURE_2D, item["texture"])
            gl.glBegin(gl.GL_QUADS)
            gl.glColor4f(r * alpha, g * alpha, b * alpha, alpha)
            gl.glTexCoord2d(0.0, 0.0)
            gl.glVertex2d(x, y)
            gl.glTexCoord2d(1.0, 0.0)
            gl.glVertex2d(x + w, y)
            gl.glTexCoord2d(1.0, 1.0)
            gl.glVertex2d(x + w, y + h)
            gl.glTexCoord2d(0.0, 1.0)
            gl.glVertex2d(x, y + h)
            gl.glEnd()

            # re-insert item at front
            text_cache.insert(0, item)
            return w, h

        # calculate size of text

        required_width, required_height = self.measure(text)

        # setup fbo

        render_texture = gl.glGenTextures(1)
        gl.glBindTexture(gl.GL_TEXTURE_2D, render_texture)
        gl.glTexImage2D(
            gl.GL_TEXTURE_2D,
            0,
            gl.GL_RGBA,
            required_width,
            required_height,
            0,
            gl.GL_RGBA,
            gl.GL_UNSIGNED_INT,
            None,
        )
        gl.glTexParameteri(
            gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE
        )
        gl.glTexParameteri(
            gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE
        )
        gl.glTexParameteri(
            gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR
        )

        # FIXME: Mipmapping?
        mip_mapping = 0
        if mip_mapping:
            gl.glTexParameteri(
                gl.GL_TEXTURE_2D,
                gl.GL_TEXTURE_MIN_FILTER,
                gl.GL_LINEAR_MIPMAP_LINEAR,
            )
            gl.glTexParameteri(
                gl.GL_TEXTURE_2D, gl.GL_GENERATE_MIPMAP, gl.GL_TRUE
            )
            gl.glGenerateMipmapEXT(gl.GL_TEXTURE_2D)
        else:
            gl.glTexParameteri(
                gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR
            )

        gl.glBindTexture(gl.GL_TEXTURE_2D, 0)

        # Set up some renderbuffer state

        frame_buffer = gl.GLuint()
        gl.glGenFramebuffersEXT(1, frame_buffer)
        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, frame_buffer)
        gl.glFramebufferTexture2DEXT(
            gl.GL_FRAMEBUFFER_EXT,
            gl.GL_COLOR_ATTACHMENT0_EXT,
            gl.GL_TEXTURE_2D,
            render_texture,
            0,
        )

        status = gl.glCheckFramebufferStatusEXT(gl.GL_FRAMEBUFFER_EXT)
        if status != gl.GL_FRAMEBUFFER_COMPLETE_EXT:
            print("glCheckFramebufferStatusEXT error", status)

        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.glPushAttrib(int(gl.GL_VIEWPORT_BIT) | int(gl.GL_ENABLE_BIT))
        gl.glViewport(0, 0, required_width, required_height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glPushMatrix()
        gl.glLoadIdentity()
        gl.gluOrtho2D(0, required_width, 0, required_height)

        gl.glClearColor(0.0, 0.0, 0.0, 0.0)
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        gl.glEnable(gl.GL_BLEND)
        gl.glEnable(gl.GL_TEXTURE_2D)

        self.texture.bind()

        tw = self.texture.w
        th = self.texture.h

        gl.glBegin(gl.GL_QUADS)
        gl.glColor4f(1.0, 1.0, 1.0, 1.0)
        x2 = 0
        h = self.h
        for ch in text:
            c = ord(ch)
            w = self.w[c]
            s1 = self.x[c] / tw
            s2 = (self.x[c] + w) / tw
            t1 = (self.y[c]) / th
            t2 = (self.y[c] + h) / th
            gl.glTexCoord2d(s1, t2)
            gl.glVertex2d(x2, 0)
            gl.glTexCoord2d(s2, t2)
            gl.glVertex2d(x2 + w, 0)
            gl.glTexCoord2d(s2, t1)
            gl.glVertex2d(x2 + w, h)
            gl.glTexCoord2d(s1, t1)
            gl.glVertex2d(x2, h)
            x2 += w
        gl.glEnd()

        gl.glPopMatrix()
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glPopAttrib()
        gl.glBindFramebufferEXT(gl.GL_FRAMEBUFFER_EXT, 0)
        gl.glPopMatrix()

        gl.glDeleteFramebuffersEXT(1, frame_buffer)

        if mip_mapping:
            gl.glBindTexture(gl.GL_TEXTURE_2D, render_texture)
            gl.glGenerateMipmapEXT(gl.GL_TEXTURE_2D)
            gl.glBindTexture(gl.GL_TEXTURE_2D, 0)

        new_item = {
            "font": self,
            "text": text,
            "w": required_width,
            "h": required_height,
            "texture": render_texture,
        }
        text_cache.insert(0, new_item)

        item = text_cache.pop()
        if item["texture"]:
            gl.glDeleteTextures([item["texture"]])

        # now the text is in the cache, so call function again
        return self.render(text, x, y, r, g, b, alpha)
示例#14
0
 def render(self):
     gl.glDisable(gl.GL_DEPTH_TEST)
     alpha = (State.get().time - self.wait_run_time) / FADE_TIME
     render_fade(0.0, 0.0, 0.0, alpha)
     gl.glEnable(gl.GL_DEPTH_TEST)
示例#15
0
    def text(self, text, font, x, y, w=0, h=0, color=(1.0, 1.0, 1.0, 1.0),
             shadow=False, shadow_color=(0, 0, 0), halign=-1):
        if not text:
            return 0, 0
        # if len(color) == 3:
        #     color = (color[0], color[1], color[2], 1.0
        try:
            alpha = color[3]
        except IndexError:
            alpha = 1.0
        color = (int(round(color[0] * 255)),
                 int(round(color[1] * 255)),
                 int(round(color[2] * 255)))

        cache_key = (text, hash(font), font.size, color, alpha)
        try:
            self.text_cache_history.remove(cache_key)
        except ValueError:
            texture = None
        else:
            texture, txtsize = self.text_cache[cache_key]

        fs_emu_blending(True)
        fs_emu_texturing(True)
        gl.glDisable(gl.GL_DEPTH_TEST)

        if texture:
            gl.glBindTexture(gl.GL_TEXTURE_2D, texture)
        else:
            txtdata, txtsize = TextRenderer(font).render_text(text, color)
            texture = Render.get().create_texture()
            gl.glBindTexture(gl.GL_TEXTURE_2D, texture)
            gl.glTexImage2D(
                gl.GL_TEXTURE_2D, 0, gl.GL_RGBA, txtsize[0], txtsize[1],
                0, gl.GL_BGRA, gl.GL_UNSIGNED_BYTE, txtdata)
            gl.glTexParameteri(
                gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR)
            gl.glTexParameteri(
                gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR)
        tw, th = (txtsize[0] * self.ortho_pscalex,
                  txtsize[1] * self.ortho_pscaley)

        tx = x
        ty = y
        if w > 0:
            if tw > w:
                tw = w
            else:
                if halign == 0:
                    tx += (w - tw) / 2
        if h > 0:
            ty += (h - th) / 2
        # ts = 4 / cls.display_height  # Step

        # glDisable(GL_TEXTURE_RECTANGLE_ARB)

        # glTexEnv(GL_TEXTURE_2D, GL_MODULATE)
        # glDisable(GL_TEXTURE_RECTANGLE)
        # fs_emu_blending(True)
        gl.glBegin(gl.GL_QUADS)
        gl.glColor4f(alpha, alpha, alpha, alpha)

        gl.glTexCoord2f(0.0, 0.0)
        gl.glVertex2f(tx, ty + th)
        gl.glTexCoord2f(1.0, 0.0)
        gl.glVertex2f(tx + tw, ty + th)
        gl.glTexCoord2f(1.0, 1.0)
        gl.glVertex2f(tx + tw, ty)
        gl.glTexCoord2f(0.0, 1.0)
        gl.glVertex2f(tx, ty)

        # glRasterPos2f(tx, ty)
        # glDrawPixels(txtsize[0], txtsize[1], GL_RGBA, GL_UNSIGNED_BYTE,
        # txtdata)
        gl.glEnd()

        # fs_emu_blending(False)
        gl.glEnable(gl.GL_DEPTH_TEST)

        self.text_cache_history.append(cache_key)
        self.text_cache[cache_key] = texture, txtsize
        if len(self.text_cache) > TEXT_CACHE_SIZE:
            cache_key = self.text_cache_history.pop(0)
            texture, txtsize = self.text_cache.pop(cache_key)
            Render.get().delete_texture_list.append(texture)

        # # FIXME:
        # shadow = False
        #
        # glDisable(GL_DEPTH_TEST)
        # fs_emu_blending(True)
        # #text = current_menu.selected_item.title
        # #if shadow:
        # txtdata, txtsize = TextRenderer(font).render_text(text, shadow_color)
        # tw, th = txtsize[0] * ortho_pscalex, txtsize[1] * ortho_pscaley
        # tx = x
        # ty = y
        # if w > 0:
        #     tx = tx + (w - tw) / 2
        # if h > 0:
        #     ty = ty + (h - th) / 2
        # #tx = 0 - tw / 2
        # #ty = -0.67
        # ts = 4 / State.get().display_height # Step
        # if shadow:
        #     glPixelTransferf(GL_ALPHA_SCALE, 0.04)
        #     for fx, fy in [(1, 1), (-1, -1), (1, -1), (-1, 1), (1, 0), (-1,
        #  0),
        #             (0, -1), (0, 1)]:
        #         glRasterPos2f(tx - fx * ts, ty - fy * ts)
        #         glDrawPixels(txtsize[0], txtsize[1], GL_RGBA,
        # GL_UNSIGNED_BYTE,
        #                 txtdata)
        #     glPixelTransferf(GL_ALPHA_SCALE, 0.01)
        #     for fx, fy in [(0, 2), (2, 0), (0, -2), (-2, 0),
        #             (1, 2), (2, 1), (-1, 2), (-2, 1), (1, -2),
        #             (2, -1), (-1, -2), (-2, -1)]:
        #         glRasterPos2f(tx - fx * ts, ty - fy * ts)
        #         glDrawPixels(txtsize[0], txtsize[1], GL_RGBA,
        # GL_UNSIGNED_BYTE,
        #                 txtdata)
        # glPixelTransferf(GL_ALPHA_SCALE, alpha)
        # rendered = font.render(text, True, color)
        # txtsize = rendered.get_size()
        # txtdata = pygame.image.tostring(rendered, "RGBA", 1)
        # glRasterPos2f(tx, ty)
        # glDrawPixels(txtsize[0], txtsize[1], GL_RGBA, GL_UNSIGNED_BYTE,
        # txtdata)
        # #glPopAttrib()
        # glPixelTransferf(GL_ALPHA_SCALE, 1.0)
        # fs_emu_blending(False)
        # glEnable(GL_DEPTH_TEST)
        return tw, th
示例#16
0
    def render(self):
        if self.first_shown_at == 0:
            self.first_shown_at = State.get().time
        # FIXME:
        # from .gamemenu import render_wall, render_screen
        # glClear(GL_DEPTH_BUFFER_BIT)
        # render_wall()
        # render_screen()

        Render.get().hd_perspective()
        fs_emu_texturing(True)
        fs_emu_blending(False)
        Texture.sidebar_background.render(
            0, 0, 1920, Texture.sidebar_background.h)

        if len(self.controller.ports) == 0:
            color = (1.0, 0.0, 0.0, 1.0)
            text = "No input configuration needed"
            Render.get().text(text, Font.main_path_font, 200, 730, 400,
                              color=color, halign=0)
            text = "Press enter or primary key to start game"
            Render.get().text(text, Font.main_path_font, 200, 670, 400,
                              color=color, halign=0)
            return

        if self.device_list_version != InputDevices.device_list_version:
            print(" -- device list version changed")
            # self.devices, info = InputDevice.get_input_devices("", 0, 100,
            # version=2)
            self.devices = DeviceManager.instance().get_devices()
            self.device_list_version = InputDevices.device_list_version
            # [{"index": 0} for x in self.devices]
            device_ids = set()
            for device in self.devices:
                device_ids.add(device.id)
                try:
                    self.device_data[device.id]["device"] = device
                except KeyError:
                    print(" -- add device info for", device.id)
                    self.device_data[device.id] = {
                        "port": 0, "device": device}
                    self.check_device(self.device_data[device.id])
            for data_key in self.device_data.keys():
                if data_key not in device_ids:
                    print(" -- removing device_data for", data_key)
                    del self.device_data[data_key]
            for input_ in self.controller.ports:
                if not input_["device_id"] in device_ids:
                    print(" -- removing device from input", input_.device_id)
                    input_["device_id"] = None

        for port, input_ in enumerate(self.controller.ports):
            center_x = 400 + 400 * port

            text = input_.name.upper()
            color = (1.0, 0.0, 0.0, 1.0)
            Render.get().text(text, Font.main_path_font, center_x - 200, 760,
                              400,
                              color=color, halign=0)
            text = input_.description.upper()
            color = (1.0, 0.0, 0.0, 1.0)
            Render.get().text(text, Font.main_path_font, center_x - 200, 730,
                              400,
                              color=color, halign=0)
            if input_.device_id:
                device = self.device_data[input_.device_id]["device"]
                color = (1.0, 0.5, 0.5, 1.0)
                text = device.name.upper()
                Render.get().text(text, Font.main_path_font, center_x - 200,
                                  680,
                                  400, color=color, halign=0)

            for j, device in enumerate(self.devices):
                device_data = self.device_data[device.id]
                # print(1, repr(device))
                if device_data["port"] != port:
                    continue
                text = device.name.upper()
                if device_data["ok"]:
                    color = (1.0, 1.0, 1.0, 1.0)
                else:
                    color = (0.5, 0.5, 0.5, 1.0)
                Render.get().text(text, Font.main_path_font, center_x - 200,
                                  600 - j * 40, 400, color=color, halign=0)

        fade = 1.0 - (State.get().time - self.first_shown_at) * 3.0
        if fade > 0.0:
            Render.get().dirty = True
            # fs_emu_blending(True)
            # fs_emu_texturing(False)
            gl.glDisable(gl.GL_DEPTH_TEST)
            Render.get().hd_perspective()
            # gl.glBegin(gl.GL_QUADS)
            # gl.glColor4f(0.0, 0.0, 0.0, fade)
            # gl.glVertex2f(0, 0)
            # gl.glVertex2f(1920, 0)
            # gl.glVertex2f(1920, 1080)
            # gl.glVertex2f(0, 1080)
            # gl.glEnd()
            Render.get().hd_perspective()
            fs_emu_texturing(True)
            fs_emu_blending(False)
            Texture.sidebar_background.render(
                0, 0, 1920, Texture.sidebar_background.h, opacity=fade)
            gl.glEnable(gl.GL_DEPTH_TEST)
示例#17
0
    def render_transparent(self, data):
        # print("GameMenu.render_transparent")
        last_menu = State.get().history[-2]
        last_menu.render_transparent(self.last_menu_data)

        if exit_transition.value < 1.0:
            opacity = 1.0 - exit_transition.value
            opacity *= 1.25
            if opacity > 1.0:
                opacity = 1.0
            Render.get().hd_perspective()
            gl.glDisable(gl.GL_DEPTH_TEST)
            fs_emu_texturing(False)
            fs_emu_blending(True)
            gl.glBegin(gl.GL_QUADS)
            gl.glColor4f(0.0, 0.0, 0.0, opacity)
            gl.glVertex2f(0.0, 0.0)
            gl.glVertex2f(1920.0, 0.0)
            gl.glVertex2f(1920.0, 1020.0)
            gl.glVertex2f(0.0, 1020.0)
            gl.glEnd()
            gl.glEnable(gl.GL_DEPTH_TEST)

        alpha = enter_transition.value * 0.75

        Render.get().hd_perspective()
        gl.glDisable(gl.GL_DEPTH_TEST)
        fs_emu_texturing(False)
        fs_emu_blending(True)
        gl.glBegin(gl.GL_QUADS)
        gl.glColor4f(0.0, 0.0, 0.0, alpha)
        # Covers, left
        gl.glVertex2f(0.0, 366.0)
        gl.glVertex2f(746.0, 366.0)
        gl.glVertex2f(746.0, 1020.0)
        gl.glVertex2f(0.0, 1020.0)
        # Covers, right
        gl.glVertex2f(1920.0 - 746.0, 366.0)
        gl.glVertex2f(1920.0, 366.0)
        gl.glVertex2f(1920.0, 1020.0)
        gl.glVertex2f(1920.0 - 746.0, 1020.0)
        # Bottom
        gl.glColor4f(0.0, 0.0, 0.0, 0.50)
        gl.glVertex2f(0.0, 0.0)
        gl.glVertex2f(1920.0, 0.0)
        gl.glVertex2f(1920.0, 366.0)
        gl.glVertex2f(0.0, 366.0)
        gl.glEnd()
        gl.glEnable(gl.GL_DEPTH_TEST)

        transition = enter_transition.value
        if exit_transition.value < 1.0:
            # transition = exit_transition.value
            transition = 1.0 + 3.0 - exit_transition.value * 3.0
        # print("render, transition = ", transition)
        self.config_list.render(transition)

        if exit_transition.value <= 0.0:
            exit_transition.value = 0.0
            # finished = 1.0
            exit_transition.start = 0
            exit_transition.on_finish()
示例#18
0
def init_display():
    global display
    global real_display_height  # , display_yoffset

    # global banner_texture, shadow_texture, gloss_texture
    # global top_texture, top_logo_texture, logo_texture
    # global missing_cover_texture, default_item_texture
    # global backdrop_texture

    logger.debug("Init OpenGL menu display")

    DisplayLists.clear()

    # on_resize()
    # depth = 0
    # FIXME: HACK / TESTING
    # if not Settings.fullscreen_menu:
    #    if windows:
    #        os.environ["SDL_VIDEO_WINDOW_POS"] = "3,29"
    #    else:
    #        os.environ["SDL_VIDEO_WINDOW_POS"] = "0,0"
    # maximize_window = (not Settings.fullscreen_menu and
    #                    Settings.windowed_size is None)

    # display_info = pygame.display.Info()
    # dw = display_info.current_w
    # dh = display_info.current_h
    # dw, dh = fsui.get_screen_size()
    # dw, dh = 100, 100
    Render.get().display_width = main_window.width
    Render.get().display_height = main_window.height

    # if Settings.fullscreen_menu:
    #     print("fullscreen is True")
    #     if windows:
    #         #resolution = (0, 0)
    #         #flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.NOFRAME \
    #         #        | pygame.FULLSCREEN
    #         os.environ["SDL_VIDEO_WINDOW_POS"] = "0,0"
    #         flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.NOFRAME
    #         #flags = flags | pygame.FULLSCREEN
    #         #if fs.linux:
    #         #    pass
    #         #else:
    #         if dw > dh * 2:
    #             # Assume dual monitor setup - hack for Linux / SDL
    #             resolution = (dw / 2, dh)
    #         else:
    #             resolution = (dw, dh)
    #     else:  # fullscreen, but not microsoft windows
    #         #resolution = (0, 0)
    #         flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.NOFRAME #|
    # pygame.FULLSCREEN
    #         if dw > dh * 2:
    #             # Assume dual monitor setup - hack for Linux / SDL
    #             resolution = (dw / 2, dh)
    #         else:
    #             resolution = (dw, dh)
    #         if linux:
    #             overscan = Config.get("display/overscan", "0,0,0,0")
    #             try:
    #                 overscan = overscan.split(",")
    #                 overscan = [int(x.strip()) for x in overscan]
    #                 print("using overscan", overscan)
    #             except Exception as e:
    #                 print("error parsing overscan from config:", repr(e))
    #                 overscan = [0, 0, 0, 0]
    #             os.environ["SDL_VIDEO_WINDOW_POS"] = "{0},{1}".format(
    #                 overscan[0], overscan[1])
    #             resolution = (resolution[0] - overscan[0] - overscan[2],
    #                           resolution[1] - overscan[1] - overscan[3])
    #         elif macosx:
    #             # FIXME: fullscreen mode does not work very well. -When
    #             # opening a fullscreen emulator from fullscreen, the emulator
    #             # crashes on glViewport. Tested with fs-amiga.
    #             #flags |= pygame.FULLSCREEN
    #
    #             # for now, we create an almost maximized window, works
    #             # quite well when the dock is set to auto-hide
    #             #resolution = (resolution[0], resolution[1] - 22)
    #
    #             # FIXME: trying LSUIPresentationMode
    #             os.environ["SDL_VIDEO_WINDOW_POS"] = "0,0"
    #
    #             # kUIModeNormal = 0
    #             # kUIModeContentSuppressed = 1
    #             # kUIModeContentHidden = 2
    #             # kUIModeAllSuppressed = 4
    #             kUIModeAllHidden = 3
    #             kUIOptionAutoShowMenuBar = 1 << 0
    #             # kUIOptionDisableAppleMenu = 1 << 2
    #             # kUIOptionDisableProcessSwitch = 1 << 3
    #             # kUIOptionDisableForceQuit = 1 << 4
    #             # kUIOptionDisableSessionTerminate = 1 << 5
    #             # kUIOptionDisableHide = 1 << 6
    #
    #             #noinspection PyUnresolvedReferences
    #             import objc
    #             #noinspection PyUnresolvedReferences
    #             from Foundation import NSBundle
    #             bundle = NSBundle.bundleWithPath_(
    #                 "/System/Library/Frameworks/Carbon.framework")
    #             objc.loadBundleFunctions(
    #                 bundle, globals(),
    #                 ((str("SetSystemUIMode"), str("III"), str("")),))
    #             #noinspection PyUnresolvedReferences
    #             SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar)
    #
    # else:
    #     if windows and maximize_window and \
    #             not Settings.window_decorations:
    #         import ctypes
    #         SPI_GETWORKAREA = 48
    #
    #         class RECT(ctypes.Structure):
    #             _fields_ = [
    #                 ("left", ctypes.c_ulong),
    #                 ("top", ctypes.c_ulong),
    #                 ("right", ctypes.c_ulong),
    #                 ("bottom", ctypes.c_ulong)]
    #
    #         m = ctypes.windll.user32
    #         r = RECT()
    #         m.SystemParametersInfoA(SPI_GETWORKAREA, 0, ctypes.byref(r), 0)
    #         x = int(r.left)
    #         y = int(r.top)
    #         w = int(r.right) - int(r.left)
    #         h = int(r.bottom) - int(r.top)
    #         print(x, y, w, h)
    #         WINDOWED_SIZE[0] = w
    #         WINDOWED_SIZE[1] = h
    #         os.environ["SDL_VIDEO_WINDOW_POS"] = "{0},{1}".format(x, y)
    #         State.get().allow_minimize = False
    #
    #     if Settings.windowed_size:
    #         print("Settings.windowed_size", Settings.windowed_size)
    #         WINDOWED_SIZE[0] = Settings.windowed_size[0]
    #         WINDOWED_SIZE[1] = Settings.windowed_size[1]
    #         Render.get().display_width = WINDOWED_SIZE[0]
    #         Render.get().display_height = WINDOWED_SIZE[1]
    #         #if dw > 1400:
    #         #    Render.get().display_width = 1280
    #         #    Render.get().display_height = 720
    #     else:
    #         Render.get().display_width = WINDOWED_SIZE[0]
    #         Render.get().display_height = WINDOWED_SIZE[1]
    #     resolution = (Render.get().display_width, Render.get().display_height)
    #     #print(resolution)
    #     #sys.exit(1)
    #     if Settings.window_decorations:
    #         flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.RESIZABLE
    #     else:
    #         flags = pygame.OPENGL | pygame.DOUBLEBUF | pygame.NOFRAME
    #
    # display_yoffset = 0
    # Mouse.set_visible(False)
    #
    # pygame.display.gl_set_attribute(pygame.GL_STENCIL_SIZE, 8)
    # pygame.display.gl_set_attribute(pygame.GL_DEPTH_SIZE, 16)
    #
    # Render.get().display_sync = ENABLE_VSYNC
    # if Render.get().display_sync:
    #     print("enabling vertical sync")
    #     os.environ["__GL_SYNC_TO_VBLANK"] = "1"
    #     pygame.display.gl_set_attribute(pygame.GL_SWAP_CONTROL, 1)
    # else:
    #     os.environ["__GL_SYNC_TO_VBLANK"] = "0"
    #     pygame.display.gl_set_attribute(pygame.GL_SWAP_CONTROL, 0)
    # pygame.display.gl_set_attribute(pygame.GL_DOUBLEBUFFER, 1)
    # fsaa = Config.get_int("video/fsaa", 0)
    # if fsaa:
    #     pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLEBUFFERS, 1)
    #     pygame.display.gl_set_attribute(pygame.GL_MULTISAMPLESAMPLES, fsaa)
    # print("pygame set display mode", resolution, flags, depth)
    # display = pygame.display.set_mode(resolution, flags, depth)
    # if not Settings.fullscreen_game:
    #     try:
    #         del os.environ["SDL_VIDEO_WINDOW_POS"]
    #     except KeyError:
    #         pass
    #
    # if app.name == "fs-uae-arcade":
    #     pygame.display.set_caption("FS-UAE Arcade")
    # else:
    #     pygame.display.set_caption("FS Game Center")
    #
    # # FIXME: DISABLING MAXIMIZE FOR DEBUGGING
    # #maximize_window = False
    # if maximize_window:
    #     print("maximizing window")
    #     SDL_Maximize()
    #     for event in pygame.event.get():
    #         if event.type == pygame.VIDEORESIZE:
    #             #WINDOWED_SIZE[0] = event.w
    #             #WINDOWED_SIZE[1] = event.h
    #             on_resize((event.w, event.h))
    #     print("DISPLAY.GET_SIZE", display.get_size())
    # else:
    #     on_resize(display.get_size())

    gl.glMatrixMode(gl.GL_MODELVIEW)

    gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA)
    gl.glClearColor(*State.get().fade_from)

    fs_emu_texturing(True)
    Texture.splash = Texture("splash.png")

    for _ in range(0):
        gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
        # gl.glClear(gl.GL_COLOR_BUFFER_BIT)
        Render.get().hd_perspective()
        Texture.splash.render(
            (1920 - Texture.splash.w) // 2,
            (1080 - Texture.splash.h) // 2, Texture.splash.w,
            Texture.splash.h)
        gl.glFinish()
        # pygame.display.flip()
        gl.glFinish()

    gl.glEnable(gl.GL_DEPTH_TEST)
示例#19
0
    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)
示例#20
0
    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
示例#21
0
 def render(self):
     gl.glDisable(gl.GL_DEPTH_TEST)
     render_fade(0.0, 0.0, 0.0, 1.0)
     gl.glEnable(gl.GL_DEPTH_TEST)