9 个版本 (5 个重大更改)
0.7.3 | 2021 年 7 月 5 日 |
---|---|
0.7.1 | 2021 年 6 月 1 日 |
0.7.0 | 2021 年 2 月 22 日 |
0.5.0 | 2020 年 12 月 28 日 |
0.1.0 | 2020 年 7 月 28 日 |
#129 in 渲染
每月 45 次下载
1MB
293 代码行
imgui-vulkano-renderer
警告:我仅在少数示例和几个项目中使用了此渲染器,因此可能存在一些问题,但它似乎可以与基本的 ImGui 使用一起工作。
支持 imgui-rs 版本 0.7.0
和 vulkano 版本 0.23.0
。
注意:目前 vulkano-win
和 imgui-winit-support
,即 vulkano 和 imgui-rs 的 winit
集成,仅支持 winit 0.24.0
,尽管当前 winit 版本是 0.25.0
。
用法
Renderer
结构被设计为替换 imgui-glium-renderer
和 imgui-gfx-renderer
(来自 imgui-rs 仓库)中的等价结构,除了 API 特定的上下文参数(Vulkano 的 Device
和 Queue
结构)。
设置
use imgui_vulkano_renderer::Renderer;
let mut renderer = Renderer::init(
&mut imgui_ctx,
device.clone(),
graphics_queue.clone(),
Format::R8G8B8A8Srgb
).unwrap();
渲染
使用 Renderer::draw_commands
函数更新缓冲区
let ui = imgui_ctx.frame();
// ... UI elements created here
let draw_data = ui.render();
let mut cmd_buf_builder = AutoCommandBufferBuilder::new(device.clone(), graphics_queue.family()).unwrap();
// add Vulkan commands to a command buffer. Here a new command buffer is used, but you can also append to an existing one.
renderer.draw_commands(&mut cmd_buf_builder, graphics_queue.clone(), target_image.clone(), draw_data).unwrap();
let cmd_buf = cmd_buf_builder.build().unwrap();
其他
可以使用以下方式重新加载字体图集纹理
renderer.reupload_font_texture(&mut imgui_ctx, device.clone(), queue.clone());
在您的 UI 中使用的纹理在 imgui::Textures
结构中查找,可以使用 Renderer::textures
访问。
示例
我将来自 imgui-rs 的几个示例进行了重写,以展示基本用法(其中大多数只需要修改 examples/support/mod.rs
中的 System
结构体的设置)。它们可以使用以下方式运行:
cargo run --example hello_world
cargo run --example custom_textures
依赖项
~53MB
~1M SLoC