Engine → Renderer → imgui_renderer.h
imgui_renderer
| Type | Class |
| Namespace | conjure::renderer |
| Include File Path | engine/include/conjure/renderer/imgui_renderer.h |
| Source File Path | engine/src/renderer/imgui/imgui_renderer.cpp |
| API ↗ | Rendering, Rendering a frame |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | explicit imgui_renderer(
create_tag); |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~imgui_renderer(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mImpl | std::unique_ptr<impl> | {} |
Functions
Public
attach_to_current_context
attach_to_current_contextvoid attach_to_current_context() noexcept;Declares this backend in the current ImGui context: io.BackendRendererName and the capability flags (ImGuiBackendFlags_RendererHasVtxOffset, and RendererHasTextures under ImGui >= 1.92), which ImGui reads at NewFrame. create() does it for a context that is current then; the owner of a context created later (engine::imgui_layer::on_attach) calls it right after creating the context, and render() does it for a context that has no renderer backend yet. Without a current context it does nothing; calling it again is harmless.
create
create[[nodiscard]] static core::result<std::unique_ptr<imgui_renderer>> create(
rhi::device &device,
rhi::shader_library &shaders,
rhi::texture_format targetFormat,
imgui_texture_resolver resolver);Builds the pipeline (imgui.hlsl: premultiplied alpha, scissor, no depth) for the given framebuffer colour format from the "imgui" program of shader_asset's built-in table, and declares the backend in the current ImGui context, if there is one (attach_to_current_context). Fails with renderer_error::SHADER_NOT_FOUND naming the shader key when the library's index lacks a stage of that program (both stages are checked before any device object is created) or a listed blob file cannot be read (found when that stage is loaded), with PIPELINE_CREATION_FAILED when the device refuses a shader, the layouts or the pipeline, and with RESOURCE_CREATION_FAILED when it refuses the sampler or the buffers. With a null resolver no registered texture ever resolves, so each draws with the font atlas texture.
font_atlas_invalidations
font_atlas_invalidations[[nodiscard]] u64 font_atlas_invalidations() const noexcept;How many times invalidate_font_atlas() was called on this backend: what an owner that rebuilds the atlas (the editor's theme applier) is checked against.
invalidate_font_atlas
invalidate_font_atlasvoid invalidate_font_atlas() noexcept;Marks the font atlas as changed so the next render() re-uploads it (ImGui 1.91: call it after io.Fonts->Build(), or reset io.Fonts->TexID to 0, which has the same effect). A no-op under the 1.92 texture protocol, where ImGui reports the change itself.
register_texture
register_texture[[nodiscard]] u64 register_texture(
gpu_texture_id texture);Makes a renderer texture usable as an ImTextureID (returned packed as a u64). The id stays valid until unregister_texture or destruction; a stale texture draws with the font atlas texture instead.
render
rendervoid render(
ImDrawData *drawData,
nvrhi::IFramebuffer *target,
nvrhi::ICommandList &commandList);Draws one frame of ImGui output into target (whose colour format matches the one given at creation). Handles the texture requests carried by the draw data first (ImGui >= 1.92) or the font atlas (1.91). Declares the backend in the current context first when that context has no renderer backend yet. A null drawData or an empty frame draws nothing.
stats
stats[[nodiscard]] const imgui_render_stats &stats() const noexcept;target_format
target_format[[nodiscard]] rhi::texture_format target_format() const noexcept;The framebuffer colour format the pipeline was built for (the swapchain's).
texture_count
texture_count[[nodiscard]] u32 texture_count() const noexcept;Number of textures the backend currently knows (font atlas and registered ones).
unregister_texture
unregister_texturevoid unregister_texture(
u64 textureId);Forgets a registered texture; unknown handles are ignored.
uses_texture_protocol
uses_texture_protocol[[nodiscard]] static bool uses_texture_protocol() noexcept;True when the running ImGui implements the 1.92 texture protocol.