Exemplo n.º 1
0
    def init(self, platform_data):
        self.init_conf.platform_data = platform_data
        bgfx.render_frame()
        bgfx.init(self.init_conf)
        bgfx.reset(
            self.width, self.height, BGFX_RESET_VSYNC, self.init_conf.resolution.format,
        )

        bgfx.set_debug(BGFX_DEBUG_TEXT)
        bgfx.set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF, 1.0, 0)

        # Create time uniform
        self.time_uniform = bgfx.create_uniform("u_time", bgfx.UniformType.VEC4)

        # Load Bunny mesh
        self.mesh = Mesh(Path(__file__).parent.parent / "assets" / "meshes" / "bunny.bin")

        # Create program from shaders.
        self.main_program = bgfx.create_program(
            load_shader(
                "mesh.VertexShader.vert", ShaderType.VERTEX, root_path=root_path
            ),
            load_shader(
                "mesh.FragmentShader.frag", ShaderType.FRAGMENT, root_path=root_path
            ),
            True,
        )

        ImGuiExtra.imgui_create()
Exemplo n.º 2
0
    def init(self, platform_data):
        self.init_conf.platform_data = platform_data
        bgfx.render_frame()
        bgfx.init(self.init_conf)
        bgfx.reset(
            self.width,
            self.height,
            BGFX_RESET_VSYNC,
            self.init_conf.resolution.format,
        )

        bgfx.set_debug(BGFX_DEBUG_TEXT)
        bgfx.set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF,
                            1.0, 0)

        self.vertex_layout = bgfx.VertexLayout()
        self.vertex_layout.begin().add(
            bgfx.Attrib.POSITION, 3,
            bgfx.AttribType.FLOAT).add(bgfx.Attrib.COLOR0, 4,
                                       bgfx.AttribType.UINT8,
                                       True).add(bgfx.Attrib.TEXCOORD0, 2,
                                                 bgfx.AttribType.FLOAT).end()

        # Create static vertex buffer
        vb_memory = bgfx.copy(as_void_ptr(cube_vertices),
                              sizeof(PosColorTexVertex) * num_vertices)
        self.vertex_buffer = bgfx.create_vertex_buffer(vb_memory,
                                                       self.vertex_layout)

        # Create index buffer
        ib_memory = bgfx.copy(as_void_ptr(cube_indices), cube_indices.nbytes)
        self.index_buffer = bgfx.create_index_buffer(ib_memory)

        # Create texture uniform
        self.texture_uniform = bgfx.create_uniform("s_tex",
                                                   bgfx.UniformType.SAMPLER)

        # Load the image using PIL and make the texture
        logo = Image.open(
            Path(__file__).parent.parent / "assets" / "textures" /
            "python_logo.png")
        logo_memory = bgfx.copy(as_void_ptr(logo.tobytes()),
                                len(logo.tobytes()))
        self.logo_texture = bgfx.create_texture2d(logo.width, logo.height,
                                                  False, 1,
                                                  bgfx.TextureFormat.RGBA8,
                                                  BGFX_TEXTURE_RT, logo_memory)

        # Create program from shaders.
        self.main_program = bgfx.create_program(
            load_shader("textures.VertexShader.vert",
                        ShaderType.VERTEX,
                        root_path=root_path),
            load_shader("textures.FragmentShader.frag",
                        ShaderType.FRAGMENT,
                        root_path=root_path),
            True,
        )

        ImGuiExtra.imgui_create()
Exemplo n.º 3
0
    def init(self, platform_data):
        self.init_conf.platform_data = platform_data
        bgfx.render_frame()
        bgfx.init(self.init_conf)

        bgfx.set_debug(BGFX_DEBUG_TEXT)
        bgfx.set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF,
                            1.0, 0)
        ImGuiExtra.imgui_create()
Exemplo n.º 4
0
    def init(self, platform_data):
        self.init_conf.platform_data = platform_data
        bgfx.render_frame()
        bgfx.init(self.init_conf)
        bgfx.reset(
            self.width,
            self.height,
            BGFX_RESET_VSYNC,
            self.init_conf.resolution.format,
        )

        bgfx.set_debug(BGFX_DEBUG_TEXT)
        bgfx.set_view_clear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355FF,
                            1.0, 0)

        self.vertex_layout = bgfx.VertexLayout()
        self.vertex_layout.begin().add(bgfx.Attrib.POSITION, 3,
                                       bgfx.AttribType.FLOAT).add(
                                           bgfx.Attrib.COLOR0, 4,
                                           bgfx.AttribType.UINT8, True).end()

        # Create static vertex buffer
        vb_memory = bgfx.copy(as_void_ptr(cube_vertices),
                              sizeof(PosColorVertex) * num_vertices)
        self.vertex_buffer = bgfx.create_vertex_buffer(vb_memory,
                                                       self.vertex_layout)

        self.index_buffers = []

        for i in range(0, len(primitives)):
            ib_memory = bgfx.copy(as_void_ptr(primitives[i]),
                                  primitives[i].nbytes)
            self.index_buffers.append(bgfx.create_index_buffer(ib_memory))

        # Create program from shaders.
        self.main_program = bgfx.create_program(
            load_shader("cubes.VertexShader.vert",
                        ShaderType.VERTEX,
                        root_path=root_path),
            load_shader("cubes.FragmentShader.frag",
                        ShaderType.FRAGMENT,
                        root_path=root_path),
            True,
        )

        ImGuiExtra.imgui_create()