def update(self, dt): self.elapsed_time += dt mouse_x, mouse_y, buttons_states = self.get_mouse_state() ImGuiExtra.imgui_begin_frame( int(mouse_x), int(mouse_y), buttons_states, 0, self.width, self.height ) show_example_dialog() ImGuiExtra.imgui_end_frame() at = (c_float * 3)(*[0.0, 1.0, 0.0]) eye = (c_float * 3)(*[0.0, 1.0, -2.5]) up = (c_float * 3)(*[0.0, 1.0, 0.0]) view = look_at(eye, at, up) projection = proj(60.0, self.width / self.height, 0.1, 100.0) bgfx.set_view_transform(0, as_void_ptr(view), as_void_ptr(projection)) bgfx.set_view_rect(0, 0, 0, self.width, self.height) bgfx.touch(0) mtx = rotate_xy( 0, self.elapsed_time * 0.37 ) bgfx.set_uniform(self.time_uniform, as_void_ptr((c_float * 4)(self.elapsed_time, 0.0, 0.0, 0.0))) self.mesh.submit(0, self.main_program, mtx) bgfx.frame()
def update(self, dt): self.elapsed_time += dt mouse_x, mouse_y, buttons_states = self.get_mouse_state() ImGuiExtra.imgui_begin_frame(int(mouse_x), int(mouse_y), buttons_states, 0, self.width, self.height) show_example_dialog() self._create_imgui_cubes_selection_dialog() ImGuiExtra.imgui_end_frame() at = (c_float * 3)(*[0.0, 0.0, 0.0]) eye = (c_float * 3)(*[0.0, 0.0, -35.0]) up = (c_float * 3)(*[0.0, 1.0, 0.0]) view = look_at(eye, at, up) projection = proj(60.0, self.width / self.height, 0.1, 100.0) bgfx.set_view_transform(0, as_void_ptr(view), as_void_ptr(projection)) bgfx.set_view_rect(0, 0, 0, self.width, self.height) bgfx.touch(0) for yy in range(0, 11): for xx in range(0, 11): mtx = rotate_xy(self.elapsed_time + xx * 0.21, self.elapsed_time + yy * 0.37) mtx[3, 0] = -15.0 + xx * 3.0 mtx[3, 1] = -15.0 + yy * 3.0 mtx[3, 2] = 0.0 bgfx.set_transform(as_void_ptr(mtx), 1) # Set vertex and index buffer. bgfx.set_vertex_buffer(0, self.vertex_buffer, 0, num_vertices) bgfx.set_index_buffer( self.index_buffers[self.primitive_geometry.value], 0, primitives[self.primitive_geometry.value].size, ) bgfx.set_state( bgfx_states[self.primitive_geometry.value] | (BGFX_STATE_WRITE_R if self.write_r.value else 0) | (BGFX_STATE_WRITE_G if self.write_g.value else 0) | (BGFX_STATE_WRITE_B if self.write_b.value else 0) | (BGFX_STATE_WRITE_A if self.write_a.value else 0) | BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS | BGFX_STATE_CULL_CW | BGFX_STATE_MSAA, 0, ) bgfx.submit(0, self.main_program, 0, False) bgfx.frame()
def update(self, dt): self.elapsed_time += dt mouse_x, mouse_y, buttons_states = self.get_mouse_state() ImGuiExtra.imgui_begin_frame(int(mouse_x), int(mouse_y), buttons_states, 0, self.width, self.height) show_example_dialog() ImGuiExtra.imgui_end_frame() at = (c_float * 3)(*[0.0, 0.0, 0.0]) eye = (c_float * 3)(*[0.0, 0.0, -15.0]) up = (c_float * 3)(*[0.0, 1.0, 0.0]) view = look_at(eye, at, up) projection = proj(60.0, self.width / self.height, 0.1, 100.0) bgfx.set_view_transform(0, as_void_ptr(view), as_void_ptr(projection)) bgfx.set_view_rect(0, 0, 0, self.width, self.height) bgfx.touch(0) for yy in range(-2, 2): for xx in range(-2, 2): mtx = rotate_xy(self.elapsed_time + xx * 0.51, self.elapsed_time + yy * 0.27) mtx[3, 0] = 4 + xx * 3.5 mtx[3, 1] = 2 + yy * 3.5 mtx[3, 2] = 0 bgfx.set_transform(as_void_ptr(mtx), 1) # Set vertex and index buffer. bgfx.set_vertex_buffer(0, self.vertex_buffer, 0, num_vertices) bgfx.set_index_buffer(self.index_buffer, 0, cube_indices.size) # Set the texture bgfx.set_texture(0, self.texture_uniform, self.logo_texture) bgfx.set_state( 0 | BGFX_STATE_WRITE_RGB | BGFX_STATE_WRITE_A | BGFX_STATE_WRITE_Z | BGFX_STATE_DEPTH_TEST_LESS | BGFX_STATE_MSAA, 0, ) bgfx.submit(0, self.main_program, 0, False) bgfx.frame()
def update(self, dt): mouse_x, mouse_y, buttons_states = self.get_mouse_state() ImGuiExtra.imgui_begin_frame(int(mouse_x), int(mouse_y), buttons_states, 0, self.width, self.height) show_example_dialog() ImGuiExtra.imgui_end_frame() bgfx.set_view_rect(0, 0, 0, self.width, self.height) bgfx.touch(0) bgfx.dbg_text_clear(0, False) bgfx.dbg_text_image( int(max(self.width / 2 / 8, 20)) - 20, int(max(self.height / 2 / 16, 6)) - 6, 40, 12, python_image.logo, 160, ) stats = bgfx.get_stats() bgfx.dbg_text_printf( 1, 1, 0x0F, "Color can be changed with ANSI \x1b[9;me\x1b[10;ms\x1b[11;mc\x1b[12;ma\x1b[13;mp\x1b[14;me\x1b[0m code too.", ) bgfx.dbg_text_printf( 80, 1, 0x0F, "\x1b[;0m \x1b[;1m \x1b[; 2m \x1b[; 3m \x1b[; 4m \x1b[; 5m \x1b[; 6m \x1b[; 7m \x1b[0m", ) bgfx.dbg_text_printf( 80, 2, 0x0F, "\x1b[;8m \x1b[;9m \x1b[;10m \x1b[;11m \x1b[;12m \x1b[;13m \x1b[;14m \x1b[;15m \x1b[0m", ) bgfx.dbg_text_printf( 1, 2, 0x0F, f"Backbuffer {stats.width}W x {stats.height}H in pixels, debug text {stats.text_width}W x {stats.text_height}H in characters.", ) bgfx.frame()