コード例 #1
0
ファイル: itemmenu.py プロジェクト: jelmer/fs-uae-debian
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)
コード例 #2
0
ファイル: window.py プロジェクト: EdwardBetts/fs-uae-launcher
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
コード例 #3
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)
コード例 #4
0
ファイル: dialog.py プロジェクト: jelmer/fs-uae-debian
 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
ファイル: window.py プロジェクト: EdwardBetts/fs-uae-launcher
def render_top():
    Render.get().hd_perspective()
    gl.glPushMatrix()
    transition = State.get().current_menu.top_menu_transition
    gl.glTranslate(0.0, (1.0 - transition) * 90, 0.9)

    gl.glTranslate(0.0, 0.0, 0.05)

    if State.get().top_menu == State.get().navigatable:
        selected_index = State.get().top_menu.get_selected_index()
    else:
        selected_index = -1
    x = State.get().gl_left
    for item in State.get().top_menu.left:
        item.update_size_left()
        item.x = x
        item.y = 1080 - TOP_HEIGHT
        item.h = TOP_HEIGHT
        x += item.w

    index = len(State.get().top_menu.left) - 1
    for item in reversed(State.get().top_menu.left):
        item.render_top_left(selected=(index == selected_index))
        index -= 1

    index = len(State.get().top_menu) - 1
    x = State.get().gl_right
    for item in reversed(State.get().top_menu.right):
        item.update_size_right()
        x -= item.w
        item.x = x
        item.y = 1080 - TOP_HEIGHT
        item.h = TOP_HEIGHT
        if Mouse.focus:
            selected = (Mouse.focus == item)
        else:
            selected = (index == selected_index)
        item.render_top_right(selected=selected)
        Mouse.items.append(item)
        index -= 1
    gl.glPopMatrix()
コード例 #6
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)
コード例 #7
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
コード例 #8
0
ファイル: itemmenu.py プロジェクト: bopopescu/fs-uae-debian
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
コード例 #9
0
ファイル: font.py プロジェクト: bopopescu/fs-uae-debian
    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)
コード例 #10
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
コード例 #11
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)