Foundation
Loading...
Searching...
No Matches
Classes | Functions | Variables
ImGui.cpp File Reference
#include "ImGui.hpp"
#include <filesystem>
#include "tracy/Tracy.hpp"
#include <RenderCore/Bindless.hpp>
#include <RenderCore/ImmediateContext.hpp>
#include <SDL3/SDL.h>
#include <imgui_impl_sdl3.h>

Classes

struct  ImGuiImplFoundationBd
 
struct  PushConstants
 

Functions

void * ImGui_ImplFoundation_MemAlloc (size_t sz, void *)
 
void ImGui_ImplFoundation_MemFree (void *ptr, void *)
 
void ImGui_ImplFoundation_Init (RHIDevice *device, SDL_Window *window)
 
void ImGui_ImplFoundation_ProcessEvent (SDL_Event *event)
 Processes one SDL event and forwards it to ImGui.
 
void ImGui_ImplFoundation_NewFrame ()
 Starts a new ImGui frame.
 
void ImGui_ImplFoundation_Shutdown ()
 Shuts down the ImGui backend and releases all resources.
 
Pair< uint32_t, ImGui_ImplFoundation_ImageSamplerImGui_ImplFoundation_DecodeImTextureID (ImTextureID id)
 
ImTextureID ImGui_ImplFoundation_EncodeImTextureID (uint32_t handle, ImGui_ImplFoundation_ImageSampler sampler=ImGuiImplFoundationImageSamplerLinear)
 
void ImGui_ImplFoundation_ImplUpdateTexture (ImTextureData *tex)
 
ImTextureID ImGui_ImplFoundation_AddImage (RHITextureView *textureView, ImGui_ImplFoundation_ImageSampler sampler)
 Registers a texture with the ImGui backend so it can be displayed in the UI.
 
void ImGui_ImplFoundation_RemoveImage (ImTextureID textureID)
 Unregisters a texture from the ImGui backend.
 
void ImGui_ImplFoundation_ImplPassSetup (PassHandle self, Renderer *r, ResourceHandle vtxBuffer, ResourceHandle idxBuffer, ResourceHandle linSampler, ResourceHandle nearSampler)
 
void ImGui_ImplFoundation_ImplPassRecord (PassHandle self, Renderer *r, bool clear, RHICommandList *cmd, ResourceHandle vtxBuffer, ResourceHandle idxBuffer)
 
void ImGui_ImplFoundation_ImplCreateResources (Renderer *renderer, ResourceHandle &outVtxBuffer, ResourceHandle &outIdxBuffer, ResourceHandle &outLinearSampler, ResourceHandle &outNearestSampler)
 
void ImGui_ImplFoundation_SetupContextWithDefaultStyles ()
 Applies a default, vaguely stylish theme to the ImGui context.
 

Variables

constexpr size_t kMaxTextures = 1024
 
constexpr size_t kUploadBudget = 16 * (1u << 20)
 
constexpr size_t kVertexBufferSize = 16 * (1u << 20)
 
constexpr size_t kIndexBufferSize = 16 * (1u << 20)
 
const char * kDefaultFontPath = "./data/assets/LXGWNeoXiHei.ttf"
 
UniquePtr< BindlessPoolgImGuiTexturePool = nullptr
 
struct ImGuiImplFoundationBd gBackendData
 

Function Documentation

◆ ImGui_ImplFoundation_AddImage()

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.

Parameters
textureViewThe texture view to be used.
samplerThe sampler to be used for the texture.
Returns
An ImTextureID that you can use with ImGui::Image() and other functions.

◆ ImGui_ImplFoundation_DecodeImTextureID()

Pair< uint32_t, ImGui_ImplFoundation_ImageSampler > ImGui_ImplFoundation_DecodeImTextureID ( ImTextureID  id)

◆ ImGui_ImplFoundation_EncodeImTextureID()

ImTextureID ImGui_ImplFoundation_EncodeImTextureID ( uint32_t  handle,
ImGui_ImplFoundation_ImageSampler  sampler = ImGuiImplFoundationImageSamplerLinear 
)

◆ ImGui_ImplFoundation_ImplCreateResources()

void ImGui_ImplFoundation_ImplCreateResources ( Renderer renderer,
ResourceHandle outVtxBuffer,
ResourceHandle outIdxBuffer,
ResourceHandle outLinearSampler,
ResourceHandle outNearestSampler 
)

◆ ImGui_ImplFoundation_ImplPassRecord()

void ImGui_ImplFoundation_ImplPassRecord ( PassHandle  self,
Renderer r,
bool  clear,
RHICommandList cmd,
ResourceHandle  vtxBuffer,
ResourceHandle  idxBuffer 
)

◆ ImGui_ImplFoundation_ImplPassSetup()

void ImGui_ImplFoundation_ImplPassSetup ( PassHandle  self,
Renderer r,
ResourceHandle  vtxBuffer,
ResourceHandle  idxBuffer,
ResourceHandle  linSampler,
ResourceHandle  nearSampler 
)

◆ ImGui_ImplFoundation_ImplUpdateTexture()

void ImGui_ImplFoundation_ImplUpdateTexture ( ImTextureData *  tex)

◆ ImGui_ImplFoundation_Init()

void ImGui_ImplFoundation_Init ( Foundation::RHI::RHIDevice device,
SDL_Window *  window 
)

@breif Initialize global context (TexturePool, etc.) for our ImGui backend Call this once context is created, within BeginSetup/EndSetup block of your Renderer.

Parameters
deviceRHIDevice of the Renderer
windowSDL_Window
clearWhether to clear the render target before drawing.
dependOn(Optional) A pass to depend on. You may want this if the prior pass writes to resources ImGui may renderer (e.g. through ImGui_ImplFoundation_AddImage). If the prior pass writes to the backbuffer as well, this is not required as dependency will be automatically created.
Note
You MUST call ImGui_ImplFoundation_Shutdown before the destruction of RHIDevice related objects. See Examples::ImGui or other ImGui backend usage for reference.

◆ ImGui_ImplFoundation_MemAlloc()

void * ImGui_ImplFoundation_MemAlloc ( size_t  sz,
void *   
)

◆ ImGui_ImplFoundation_MemFree()

void ImGui_ImplFoundation_MemFree ( void *  ptr,
void *   
)

◆ ImGui_ImplFoundation_NewFrame()

void ImGui_ImplFoundation_NewFrame ( )

Starts a new ImGui frame.

Note
You should call this once per frame, before any other ImGui calls. See Examples::ImGui or other ImGui backend usage for reference.

◆ ImGui_ImplFoundation_ProcessEvent()

void ImGui_ImplFoundation_ProcessEvent ( SDL_Event *  event)

Processes one SDL event and forwards it to ImGui.

Parameters
eventThe SDL event to be processed.
Note
You should call this for each SDL event in your main event loop, i.e. while (SDL_PollEvent(&event)) { ImGui_ImplFoundation_ProcessEvent(&event); }

◆ ImGui_ImplFoundation_RemoveImage()

void ImGui_ImplFoundation_RemoveImage ( ImTextureID  textureID)

Unregisters a texture from the ImGui backend.

Parameters
textureIDThe ID returned by ImGui_ImplFoundation_AddImage.
Note
Call this when you no longer need the texture in the UI to free up resources.

◆ ImGui_ImplFoundation_SetupContextWithDefaultStyles()

void ImGui_ImplFoundation_SetupContextWithDefaultStyles ( )

Applies a default, vaguely stylish theme to the ImGui context.

Note
Call this after ImGui_ImplFoundation_Init if you don't want to set up your own styles.

◆ ImGui_ImplFoundation_Shutdown()

void ImGui_ImplFoundation_Shutdown ( )

Shuts down the ImGui backend and releases all resources.

Note
You MUST call ImGui_ImplFoundation_Shutdown before the destruction of RHIDevice related objects. See Examples::ImGui or other ImGui backend usage for reference.

Variable Documentation

◆ gBackendData

struct ImGuiImplFoundationBd gBackendData

◆ gImGuiTexturePool

UniquePtr<BindlessPool> gImGuiTexturePool = nullptr

◆ kDefaultFontPath

const char* kDefaultFontPath = "./data/assets/LXGWNeoXiHei.ttf"

◆ kIndexBufferSize

constexpr size_t kIndexBufferSize = 16 * (1u << 20)
constexpr

◆ kMaxTextures

constexpr size_t kMaxTextures = 1024
constexpr

◆ kUploadBudget

constexpr size_t kUploadBudget = 16 * (1u << 20)
constexpr

◆ kVertexBufferSize

constexpr size_t kVertexBufferSize = 16 * (1u << 20)
constexpr