Foundation
Loading...
Searching...
No Matches
ImGui.hpp
Go to the documentation of this file.
1#pragma once
2#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
3#define IMGUI_DEFINE_MATH_OPERATORS
4#define IMGUI_DISABLE_DEFAULT_ALLOCATORS
5#include <SDL3/SDL.h>
6#include <imgui.h>
7
8#include <RHICore/Device.hpp>
18
19/* -- Internals -- */
20void ImGui_ImplFoundation_ImplUpdateTexture(ImTextureData* tex);
27 Foundation::Core::StringView customVS = "",
28 Foundation::Core::StringView customFS = "");
30 Foundation::RenderCore::Renderer* renderer, bool clear,
39// ^^^ Internals
40
41/* -- APIs -- */
56void ImGui_ImplFoundation_Init(Foundation::RHI::RHIDevice* device, SDL_Window* window);
57
64void ImGui_ImplFoundation_ProcessEvent(SDL_Event* event);
71
78
85ImTextureID
88
94void ImGui_ImplFoundation_RemoveImage(ImTextureID textureID);
95
108template <typename FSetup, typename FRecordPrologue>
110 Foundation::Core::StringView name, bool clear,
111 FSetup&& setup, FRecordPrologue&& recordPrologue)
112{
113 using namespace Foundation;
114 using namespace RenderCore;
115 using namespace RHI;
116 ResourceHandle vtxBuffer, idxBuffer, linSampler, nearSampler;
117 ImGui_ImplFoundation_ImplCreateResources(renderer, vtxBuffer, idxBuffer, linSampler, nearSampler);
118 return renderer->CreatePass(
119 "ImGui", RHIDeviceQueueType::Graphics, 0u,
120 [=](PassHandle self, Renderer* r)
121 {
122 ImGui_ImplFoundation_ImplPassSetup(self, r, vtxBuffer, idxBuffer, linSampler, nearSampler);
123 setup(self, r);
124 },
125 [=](PassHandle self, Renderer* r, RHICommandList* cmd)
126 {
127 recordPrologue(self, r, cmd);
128 ImGui_ImplFoundation_ImplPassRecord(self, r, clear, cmd, vtxBuffer, idxBuffer);
129 });
130}
131
132template <typename FSetup>
134{
135 return ImGui_ImplFoundation_CreatePass(renderer, name, clear, std::forward<FSetup>(setup),
137}
138
139
145// ^^^ APIs
Foundation::RenderCore::PassHandle ImGui_ImplFoundation_CreatePass(Foundation::RenderCore::Renderer *renderer, Foundation::Core::StringView name, bool clear, FSetup &&setup, FRecordPrologue &&recordPrologue)
Creates a render pass that will draw the ImGui UI.
Definition ImGui.hpp:109
void ImGui_ImplFoundation_NewFrame()
Starts a new ImGui frame.
Definition ImGui.cpp:55
ImTextureID ImGui_ImplFoundation_AddImage(Foundation::RHI::RHITextureView *textureView, ImGui_ImplFoundation_ImageSampler sampler=ImGuiImplFoundationImageSamplerLinear)
Registers a texture with the ImGui backend so it can be displayed in the UI.
Definition ImGui.cpp:172
void ImGui_ImplFoundation_Shutdown()
Shuts down the ImGui backend and releases all resources.
Definition ImGui.cpp:59
void ImGui_ImplFoundation_SetupContextWithDefaultStyles()
Applies a default, vaguely stylish theme to the ImGui context.
Definition ImGui.cpp:365
void ImGui_ImplFoundation_ImplUpdateTexture(ImTextureData *tex)
Definition ImGui.cpp:76
void ImGui_ImplFoundation_ImplPassSetup(Foundation::RenderCore::PassHandle self, Foundation::RenderCore::Renderer *renderer, Foundation::RenderCore::ResourceHandle vtxBuffer, Foundation::RenderCore::ResourceHandle idxBuffer, Foundation::RenderCore::ResourceHandle linSampler, Foundation::RenderCore::ResourceHandle nearSampler, Foundation::Core::StringView customVS="", Foundation::Core::StringView customFS="")
void ImGui_ImplFoundation_RemoveImage(ImTextureID textureID)
Unregisters a texture from the ImGui backend.
Definition ImGui.cpp:178
ImGui_ImplFoundation_ImageSampler
Sampler type for added image.
Definition ImGui.hpp:14
@ ImGuiImplFoundationImageSamplerLinear
Definition ImGui.hpp:15
@ ImGuiImplFoundationImageSamplerNearest
Definition ImGui.hpp:16
void ImGui_ImplFoundation_ImplCreateResources(Foundation::RenderCore::Renderer *renderer, Foundation::RenderCore::ResourceHandle &outVtxBuffer, Foundation::RenderCore::ResourceHandle &outIdxBuffer, Foundation::RenderCore::ResourceHandle &outLinearSampler, Foundation::RenderCore::ResourceHandle &outNearestSampler)
void ImGui_ImplFoundation_ProcessEvent(SDL_Event *event)
Processes one SDL event and forwards it to ImGui.
Definition ImGui.cpp:51
void ImGui_ImplFoundation_Init(Foundation::RHI::RHIDevice *device, SDL_Window *window)
Definition ImGui.cpp:33
void ImGui_ImplFoundation_ImplPassRecord(Foundation::RenderCore::PassHandle self, Foundation::RenderCore::Renderer *renderer, bool clear, Foundation::RHI::RHICommandList *cmd, Foundation::RenderCore::ResourceHandle vtxBuffer, Foundation::RenderCore::ResourceHandle idxBuffer)
Definition Command.hpp:42
Definition Device.hpp:245
Definition Resource.hpp:238
Renderer implementing a Frame Graph system with automatic resource tracking and synchronization.
Definition Renderer.hpp:89
PassHandle CreatePass(StringView name, RHIDeviceQueueType queue, size_t priority, FSetup &&setup, FRecord &&record)
Create a render pass from a Setup(Renderer*, PassHandle) and Record(Renderer*, PassHandle,...
Definition Renderer.hpp:370
std::basic_string_view< char > StringView
Alias for std::basic_string_view<char>
Definition Container.hpp:55
Handle ResourceHandle
Definition RenderPass.hpp:11
Handle PassHandle
Definition RenderPass.hpp:10
Definition Allocator.hpp:5
Default "no-op" functor for Record()
Definition RenderPass.hpp:53