Struct imgui_rs_vulkan_renderer::Renderer[][src]

pub struct Renderer { /* fields omitted */ }

Vulkan renderer for imgui.

It records rendering command to the provided command buffer at each call to cmd_draw. When done with the renderer you should call destroy before droping it to release all Vulkan resources held by the renderer.

All methods take a reference to a type implementing the RendererVkContext trait.

The renderer holds a set of vertex/index buffers per in flight frames. Vertex and index buffers are resized at each call to cmd_draw if draw data does not fit.

Implementations

impl Renderer[src]

pub fn new<C: RendererVkContext>(
    vk_context: &C,
    in_flight_frames: usize,
    render_pass: RenderPass,
    imgui: &mut Context
) -> RendererResult<Self>
[src]

Initialize and return a new instance of the renderer.

At initialization all Vulkan resources are initialized and font texture is created and uploaded to the gpu. Vertex and index buffers are not created yet.

Arguments

  • vk_context - A reference to a type implementing the RendererVkContext trait.
  • in_flight_frames - The number of in flight frames of the application.
  • render_pass - The render pass used to render the gui.
  • imgui - The imgui context.

Errors

  • RendererError - If the number of in flight frame in incorrect.
  • RendererError - If any Vulkan or io error is encountered during initialization.

pub fn set_render_pass<C: RendererVkContext>(
    &mut self,
    vk_context: &C,
    render_pass: RenderPass
) -> RendererResult<()>
[src]

Change the render pass to render to.

Useful if you need to render to a new render pass but don't want to rebuild the entire renderer. It will rebuild the graphics pipeline from scratch so it is an expensive operation.

Arguments

  • vk_context - A reference to a type implementing the RendererVkContext trait.
  • render_pass - The render pass used to render the gui.

Errors

pub fn textures(&mut self) -> &mut Textures<DescriptorSet>[src]

Returns the texture mapping used by the renderer to lookup textures.

Textures are provided by the application as vk::DescriptorSets.

Example

let descriptor_set = ...;
// Insert a vk::DescriptorSet in the renderer textures map.
// The renderer returns a generated texture id.
let texture_id = renderer.textures().insert(descriptor_set);
...
// Create an `Image` that references the texture by its id.
Image::new(texture_id, [100, 100]).build(&ui);

Caveat

Provided vk::DescriptorSets must be created with a descriptor set layout that is compatible with the one used by the renderer. See Pipeline Layout Compatibility.

pub fn cmd_draw<C: RendererVkContext>(
    &mut self,
    vk_context: &C,
    command_buffer: CommandBuffer,
    draw_data: &DrawData
) -> RendererResult<()>
[src]

Record commands required to render the gui.RendererError.

Arguments

  • vk_context - A reference to a type implementing the RendererVkContext trait.
  • command_buffer - The Vulkan command buffer that command will be recorded to.
  • draw_data - A reference to the imgui DrawData containing rendering data.

Errors

pub fn destroy<C: RendererVkContext>(
    &mut self,
    context: &C
) -> RendererResult<()>
[src]

Destroy Vulkan resources held by the renderer.

Arguments

Errors

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.