Giter VIP home page Giter VIP logo

imgui-vulkano-renderer's Introduction

crates.io API Docs Liscense

imgui-vulkano-renderer

A vulkano-based renderer for imgui-rs.

Warning: I've only used this renderer in a few examples and a couple projects, so there are likely some issues, but it seems to work with basic ImGui usage.

Supports imgui-rs version 0.7.0 and vulkano version 0.23.0.

Note: Currently vulkano-win and imgui-winit-support, the vulkano and imgui-rs winit integrations, only support winit 0.24.0, even though the current winit version is 0.25.0.

Usage

The Renderer struct is designed to be a drop-in replacement for the equivalent in imgui-glium-renderer and imgui-gfx-renderer (from the imgui-rs repository), modulo the API-specific context arguments (the Vulkano Device and Queue structs).

Setup:

use imgui_vulkano_renderer::Renderer;

let mut renderer = Renderer::init(
    &mut imgui_ctx,
    device.clone(),
    graphics_queue.clone(),
    Format::R8G8B8A8Srgb
).unwrap();

Rendering:

Use the Renderer::draw_commands function to update buffers and

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();

Misc.

The font altas texture can be reloaded with the following:

renderer.reupload_font_texture(&mut imgui_ctx, device.clone(), queue.clone());

Textures used in your UI are looked up in an imgui::Textures struct, which can be accessed with Renderer::textures.

Examples

I rewrote a couple of examples from imgui-rs to show basic usage (most of them only needed setup changes to the System struct in examples/support/mod.rs). They can be run with:

cargo run --example hello_world
cargo run --example custom_textures

imgui-vulkano-renderer's People

Contributors

fayalalebrun avatar paradyx avatar tenebryo avatar

Watchers

 avatar  avatar

Forkers

leonmatthes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.