Esempio n. 1
0
 def update(self, dt):
     bgfx.set_view_rect(0, 0, 0, self.width, self.height)
     bgfx.touch(0)
     bgfx.dbg_text_clear(0, False)
     bgfx.dbg_text_image(max(self.width / 2 / 8, 20) - 20,
                         max(self.height / 2 / 16, 6) - 12,
                         40,
                         27,
                         python_image.s_python_logo,
                         80)
     bgfx.dbg_text_printf(0, 1, 0x4f, self.title)
     bgfx.dbg_text_printf(
         0, 2, 0x6f, "Description: Initialization and debug text.")
     bgfx.frame()
Esempio n. 2
0
    def update(self, dt):
        # Set view 0 default viewport
        bgfx.set_view_rect(0, 0, 0, self.width, self.height)

        # Set view 1 default viewport
        bgfx.set_view_rect(1, 0, 0, self.width, self.height)

        bgfx.touch(0)

        bgfx.dbg_text_clear(0, False)
        bgfx.dbg_text_printf(0, 1, 0x4f, self.title)
        bgfx.dbg_text_printf(0, 2, 0x6f, "Description: Updating shader uniforms.")
        bgfx.dbg_text_printf(0, 3, 0x0f, "Frame: %.3f [ms]" % (dt * 1000))

        at = (c_float * 3)(*[0.0, 0.0, 0.0])
        eye = (c_float * 3)(*[0.0, 0.0, -15.0])

        view = (c_float * 16)(*[1.0, 0.0, 0.0, 0.0,
                                0.0, 1.0, 0.0, 0.0,
                                0.0, 0.0, 1.0, 0.0,
                                -0.0, -0.0, 15.0, 1.0])
        proj = (c_float * 16)(*[0.974278629, 0.0, 0.0, 0.0,
                                0.0, 1.73205090, 0.0, 0.0,
                                0.0, -0.0, 1.00100100, 1.0,
                                0.0, 0.0, -0.100100100, 0.0])

        bgfx.set_view_transform(0, view, proj)

        ortho = (c_float * 16)(*[0.00156250002, 0.0, 0.0, 0.0,
                                0.0, -0.00277777785, 0.0, 0.0,
                                0.0, 0.0, 0.00999999978, 1.0,
                                -1.0, 1.0, -0.0, 1.0])

        bgfx.set_view_transform(1, None, ortho)

        light_dir = (c_float * 4)(*[-0.3369, -0.4209, -0.842, 0.000136])
        bgfx.set_uniform(self.u_light_dir_time, light_dir, 1)

        inv_mvp = (c_float * 16)(*[1.02640045, 0.0, 0.0, 0.0,
                                   0.0, 0.577350199, 0.0, 0.0,
                                   0.00756994542, -0.0204593129, 149.849350, -9.98995686,
                                  -0.00752700586, 0.0203432590, -148.999344, 9.99995613])
        bgfx.set_uniform(self.u_mtx, inv_mvp, 1)

        render_screen_space_quad(1, self.raymarching, self.ms_decl, 0.0, 0.0, self.width, self.height)

        bgfx.frame()