HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions
v1::gfx_surface_delegate Class Reference

#include <hikogui/GFX/gfx_surface_delegate_vulkan.hpp>

Public Member Functions

 gfx_surface_delegate (gfx_surface_delegate const &)=delete
 
 gfx_surface_delegate (gfx_surface_delegate &&)=delete
 
gfx_surface_delegateoperator= (gfx_surface_delegate const &)=delete
 
gfx_surface_delegateoperator= (gfx_surface_delegate &&)=delete
 
virtual void teardown_for_swapchain_lost () noexcept
 The swap-chain is going to be teared-down.
 
virtual void teardown_for_device_lost () noexcept
 The vulkan device is going to be teared-down.
 
virtual void build_for_new_device (VmaAllocator allocator, vk::Instance instance, vk::Device device, vk::Queue graphics_queue, uint32_t graphics_queue_family_index) noexcept
 The vulkan device has been initialized.
 
virtual void build_for_new_swapchain (std::vector< vk::ImageView > const &views, vk::Extent2D size, vk::SurfaceFormatKHR format) noexcept
 The swap-chain has been build.
 
virtual void draw (uint32_t swapchain_index, vk::Semaphore start, vk::Semaphore finish, vk::Rect2D render_area) noexcept
 Draw using vulkan API.
 

Detailed Description

A delegate for drawing on a window below the HikoGUI user interface.

This delegate is used to handle drawing on the window outside the HikoGUI user interface. This means you can draw into the swap-chain before HikoGUI layers the user interface on top of it.

Member Function Documentation

◆ build_for_new_device()

virtual void v1::gfx_surface_delegate::build_for_new_device ( VmaAllocator allocator,
vk::Instance instance,
vk::Device device,
vk::Queue graphics_queue,
uint32_t graphics_queue_family_index )
inlinevirtualnoexcept

The vulkan device has been initialized.

This function is called when either the device has just been build, or when the widget is added to a window with the device already existing.

Parameters
allocatorThe vulkan-memory-allocator used for reserving memory by HikoGUI.
instanceThe vulkan instance used by HikoGUI.
deviceThe vulkan device used by HikoGUI.
graphics_queueThe graphics queue for rendering on the swap-chain.
graphics_queue_family_indexThe family-index of the graphics_queue.

◆ build_for_new_swapchain()

virtual void v1::gfx_surface_delegate::build_for_new_swapchain ( std::vector< vk::ImageView > const & views,
vk::Extent2D size,
vk::SurfaceFormatKHR format )
inlinevirtualnoexcept

The swap-chain has been build.

This function is called when either the swap-chain has just been build, or when the delegate is added to a window with an already existing swap-chain.

The swap-chain will also be build during resizing of the window. So this needs to be rather fast.

Parameters
viewsThe list of swap-chain image views.
sizeThe size of the images in the swap-chain.
formatThe pixel format and color space of the images in the swap-chain.

◆ draw()

virtual void v1::gfx_surface_delegate::draw ( uint32_t swapchain_index,
vk::Semaphore start,
vk::Semaphore finish,
vk::Rect2D render_area )
inlinevirtualnoexcept

Draw using vulkan API.

HikoGUI reuses previously drawn swap-chain images to reduce the amount of drawing; therefor:

  • Set the initialLayout of the attachment description to VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
  • Set the renderArea of the render-pass to @ render_area.
  • Ensure with a scissor that no drawing is done outside the @ render_area.

See VkRenderPassBeginInfo

Parameters
swapchain_indexThe index of the image-view of the swap-chain to draw into.
startThe semaphore used to signal when the swapchain-image is ready to be drawn.
finishThe semaphore used to signal when finishing drawing into the swapchain-image.
render_areaThe area of the window that is being drawn.

◆ teardown_for_device_lost()

virtual void v1::gfx_surface_delegate::teardown_for_device_lost ( )
inlinevirtualnoexcept

The vulkan device is going to be teared-down.

◆ teardown_for_swapchain_lost()

virtual void v1::gfx_surface_delegate::teardown_for_swapchain_lost ( )
inlinevirtualnoexcept

The swap-chain is going to be teared-down.

This function is called just before the swap-chain is being teared down.

This requires the destruction of any references to the swap-chain's image views, including the frame-buffers created during swapchain_build().


The documentation for this class was generated from the following file: