This sample demonstrates rendering a single-color texture to the viewport, bypassing direct swapchain image rendering.
The sample utilizes a 1x1 texture to display a user-selected color, updating dynamically based on GUI input.
In main():
nvvkhl::Applicationis instantiated usingnvvkhl::ApplicationCreateInfo.- This initializes the Vulkan instance, device, physical device, GLFW window, and Dear ImGui.
- For detailed initialization steps, refer to
nvvkhl::Application::init().
- The
SolidColorsample is created, derived fromnvvkhl::IAppElement.
In onAttach():
AllocVmais instantiated, deriving fromnvvk::ResourceAllocator.- This core helper class from
nvpro_core/nvvkfacilitates efficient resource creation. - The sample utilizes Vulkan Memory Allocator (VMA) for memory management.
- This core helper class from
- A 1x1 texture is created for color display.
The application enters an infinite loop via ->run() until closure is requested. Each iteration invokes:
onUIRender(): Renders the GUI in the "Settings" window.onUIMenu(): Handles menu interactions.onResize(w,h): Manages viewport resizing.onRender(cmd): Executes per-frame rendering logic.
- The texture is displayed as a UI element in the "Viewport" window using
ImGui::Image(). onRender()is called each frame.- If color changes are detected,
setData(cmd)updates the texture with the new color selected in the GUI.
This implementation showcases efficient texture updating and rendering techniques within a Vulkan-based application framework.
