Struct imgui_rs_vulkan_renderer::Renderer [−][src]
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]
vk_context: &C,
in_flight_frames: usize,
render_pass: RenderPass,
imgui: &mut Context
) -> RendererResult<Self>
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 theRendererVkContext
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]
&mut self,
vk_context: &C,
render_pass: RenderPass
) -> RendererResult<()>
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 theRendererVkContext
trait.render_pass
- The render pass used to render the gui.
Errors
RendererError
- If any Vulkan error is encountered during pipeline creation.RendererError
- If the method is call afterdestroy
was called.
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::DescriptorSet
s.
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::DescriptorSet
s 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]
&mut self,
vk_context: &C,
command_buffer: CommandBuffer,
draw_data: &DrawData
) -> RendererResult<()>
Record commands required to render the gui.RendererError.
Arguments
vk_context
- A reference to a type implementing theRendererVkContext
trait.command_buffer
- The Vulkan command buffer that command will be recorded to.draw_data
- A reference to the imguiDrawData
containing rendering data.
Errors
RendererError
- If any Vulkan error is encountered during command recording.RendererError
- If the method is call afterdestroy
was called.
pub fn destroy<C: RendererVkContext>(
&mut self,
context: &C
) -> RendererResult<()>
[src]
&mut self,
context: &C
) -> RendererResult<()>
Destroy Vulkan resources held by the renderer.
Arguments
vk_context
- A reference to a type implementing theRendererVkContext
trait.
Errors
RendererError
- If the method is call afterdestroy
was called.
Auto Trait Implementations
impl RefUnwindSafe for Renderer
[src]
impl Send for Renderer
[src]
impl Sync for Renderer
[src]
impl Unpin for Renderer
[src]
impl UnwindSafe for Renderer
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,