Foundation
Loading...
Searching...
No Matches
Classes | Functions | Variables
ImGui.cpp File Reference
#include "ImGui.hpp"
#include <Bits/Format.hpp>
#include <Core/DefaultAllocator.hpp>
#include <Rendering/UploadContext.hpp>
#include <imgui_impl_glfw.h>
#include "tracy/Tracy.hpp"

Classes

struct  PushConstants
 

Functions

voidImGui_ImplFoundation_MemAlloc (size_t sz, void *)
 
void ImGui_ImplFoundation_MemFree (void *ptr, void *)
 
void ImGui_ImplFoundation_Init (RHIDevice *device, Native::NativeWindow *window, Allocator *allocator)
 
void ImGui_ImplFoundation_NewFrame ()
 Starts a new ImGui frame.
 
void ImGui_ImplFoundation_Shutdown ()
 Shuts down the ImGui backend and releases all resources.
 
Pair< TexturePoolHandle, ImGui_ImplFoundation_ImageSamplerImGui_ImplFoundation_DecodeImTextureID (ImTextureID id)
 
ImTextureID ImGui_ImplFoundation_EncodeImTextureID (TexturePoolHandle 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_MB
 
constexpr size_t kVertexBufferSize = 8_MB
 
constexpr size_t kIndexBufferSize = 4_MB
 
const Native::Path kDefaultFontPath = "./data/assets/LXGWNeoXiHei.ttf"
 
UniquePtr< TexturePoolgImGuiTexturePool
 
UniquePtr< UploadContextgImGuiUploadContext
 
DefaultAllocator gImGuiAllocator
 

Function Documentation

◆ ImGui_ImplFoundation_AddImage()

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.
Examples
MipGeneration.cpp.

◆ ImGui_ImplFoundation_DecodeImTextureID()

Pair< TexturePoolHandle, ImGui_ImplFoundation_ImageSampler > ImGui_ImplFoundation_DecodeImTextureID ( ImTextureID  id)

◆ ImGui_ImplFoundation_EncodeImTextureID()

ImTextureID ImGui_ImplFoundation_EncodeImTextureID ( TexturePoolHandle  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,
Foundation::Native::NativeWindow window,
Foundation::Core::Allocator allocator 
)

@breif Initialize global context (TexturePool, etc) for our ImGui backend

Parameters
deviceRHIDevice of the Renderer
windowNativeWindow that the current RHISwapchain is constructed upon
allocatorAllocator used for ImGui and internal state tracking.
Note
You MUST call ImGui_ImplFoundation_Shutdown before the destruction of RHIDevice related objects. See Examples::ImGui or other ImGui backend usage for reference.
Examples
ImGui.cpp, and MipGeneration.cpp.

◆ 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.
Examples
ImGui.cpp, and MipGeneration.cpp.

◆ 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.
Examples
MipGeneration.cpp.

◆ 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.
Examples
ImGui.cpp, and MipGeneration.cpp.

◆ 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.
Examples
ImGui.cpp, and MipGeneration.cpp.

Variable Documentation

◆ gImGuiAllocator

DefaultAllocator gImGuiAllocator

◆ gImGuiTexturePool

UniquePtr<TexturePool> gImGuiTexturePool

◆ gImGuiUploadContext

UniquePtr<UploadContext> gImGuiUploadContext

◆ kDefaultFontPath

const Native::Path kDefaultFontPath = "./data/assets/LXGWNeoXiHei.ttf"

◆ kIndexBufferSize

constexpr size_t kIndexBufferSize = 4_MB
constexpr

◆ kMaxTextures

constexpr size_t kMaxTextures = 1024
constexpr

◆ kUploadBudget

constexpr size_t kUploadBudget = 16_MB
constexpr

◆ kVertexBufferSize

constexpr size_t kVertexBufferSize = 8_MB
constexpr