Textures: Single Textures[] array allows backend to not have to care about atlases.
# Conflicts: # imgui.h
This commit is contained in:
@@ -1271,6 +1271,7 @@ static void UpdateKeyRoutingTable(ImGuiKeyRoutingTable* rt);
|
|||||||
// Misc
|
// Misc
|
||||||
static void UpdateFontsNewFrame();
|
static void UpdateFontsNewFrame();
|
||||||
static void UpdateTexturesNewFrame();
|
static void UpdateTexturesNewFrame();
|
||||||
|
static void UpdateTexturesEndFrame();
|
||||||
static void UpdateSettings();
|
static void UpdateSettings();
|
||||||
static int UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_hovered, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
|
static int UpdateWindowManualResize(ImGuiWindow* window, const ImVec2& size_auto_fit, int* border_hovered, int* border_held, int resize_grip_count, ImU32 resize_grip_col[4], const ImRect& visibility_rect);
|
||||||
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
static void RenderWindowOuterBorders(ImGuiWindow* window);
|
||||||
@@ -5182,6 +5183,18 @@ static void ImGui::UpdateTexturesNewFrame()
|
|||||||
ImFontAtlasUpdateNewFrame(atlas);
|
ImFontAtlasUpdateNewFrame(atlas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build a single texture list
|
||||||
|
// We want to avoid user reading from atlas->TexList[] in order to facilitate better support for multiple atlases.
|
||||||
|
static void ImGui::UpdateTexturesEndFrame()
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImFontAtlas* atlas = g.IO.Fonts;
|
||||||
|
g.PlatformIO.Textures.resize(0);
|
||||||
|
g.PlatformIO.Textures.reserve(atlas->TexList.Size);
|
||||||
|
for (ImTextureData* tex : atlas->TexList)
|
||||||
|
g.PlatformIO.Textures.push_back(tex);
|
||||||
|
}
|
||||||
|
|
||||||
// Called once a frame. Followed by SetCurrentFont() which sets up the remaining data.
|
// Called once a frame. Followed by SetCurrentFont() which sets up the remaining data.
|
||||||
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
|
// FIXME-VIEWPORT: the concept of a single ClipRectFullscreen is not ideal!
|
||||||
static void SetupDrawListSharedData()
|
static void SetupDrawListSharedData()
|
||||||
@@ -5759,6 +5772,8 @@ void ImGui::EndFrame()
|
|||||||
g.Windows.swap(g.WindowsTempSortBuffer);
|
g.Windows.swap(g.WindowsTempSortBuffer);
|
||||||
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
|
g.IO.MetricsActiveWindows = g.WindowsActiveCount;
|
||||||
|
|
||||||
|
UpdateTexturesEndFrame();
|
||||||
|
|
||||||
// Unlock font atlas
|
// Unlock font atlas
|
||||||
g.IO.Fonts->Locked = false;
|
g.IO.Fonts->Locked = false;
|
||||||
|
|
||||||
|
|||||||
@@ -3496,7 +3496,7 @@ enum ImFontAtlasFlags_
|
|||||||
// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas).
|
// - Mouse cursor shapes for software cursor rendering (unless setting 'Flags |= ImFontAtlasFlags_NoMouseCursors' in the font atlas).
|
||||||
// - If you don't call any AddFont*** functions, the default font embedded in the code will be loaded for you.
|
// - If you don't call any AddFont*** functions, the default font embedded in the code will be loaded for you.
|
||||||
// It is the rendering backend responsibility to upload texture into your graphics API:
|
// It is the rendering backend responsibility to upload texture into your graphics API:
|
||||||
// - ImGui_ImplXXXX_RenderDrawData() functions generally iterate atlas->TexList[] to create/update/destroy each ImTextureData instance.
|
// - ImGui_ImplXXXX_RenderDrawData() functions generally iterate platform_io->Textures[] to create/update/destroy each ImTextureData instance.
|
||||||
// - Backend then set ImTextureData's TexID and BackendUserData.
|
// - Backend then set ImTextureData's TexID and BackendUserData.
|
||||||
// - Texture id are passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
|
// - Texture id are passed back to you during rendering to identify the texture. Read FAQ entry about ImTextureID for more details.
|
||||||
// Legacy path:
|
// Legacy path:
|
||||||
@@ -3597,11 +3597,9 @@ struct ImFontAtlas
|
|||||||
int TexGlyphPadding; // FIXME: Should be called "TexPackPadding". Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0 (will also need to set AntiAliasedLinesUseTex = false).
|
int TexGlyphPadding; // FIXME: Should be called "TexPackPadding". Padding between glyphs within texture in pixels. Defaults to 1. If your rendering method doesn't rely on bilinear filtering you may set this to 0 (will also need to set AntiAliasedLinesUseTex = false).
|
||||||
void* UserData; // Store your own atlas related user-data (if e.g. you have multiple font atlas).
|
void* UserData; // Store your own atlas related user-data (if e.g. you have multiple font atlas).
|
||||||
|
|
||||||
// Output
|
|
||||||
ImTextureData* TexData; // Current texture
|
|
||||||
ImVector<ImTextureData*> TexList; // Texture list (most often TexList.Size == 1). TexData is always == TexList.back().
|
|
||||||
|
|
||||||
// [Internal]
|
// [Internal]
|
||||||
|
ImTextureData* TexData; // Current texture
|
||||||
|
ImVector<ImTextureData*> TexList; // Texture list (most often TexList.Size == 1). TexData is always == TexList.back(). DO NOT USE DIRECTLY, USE GetPlatformIO().Textures[] instead!
|
||||||
bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
|
bool Locked; // Marked as Locked by ImGui::NewFrame() so attempt to modify the atlas will assert.
|
||||||
bool TexIsBuilt; // Set when texture was built matching current font input
|
bool TexIsBuilt; // Set when texture was built matching current font input
|
||||||
bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format or conversion process.
|
bool TexPixelsUseColors; // Tell whether our texture data is known to use colors (rather than just alpha channel), in order to help backend select a format or conversion process.
|
||||||
@@ -3788,6 +3786,13 @@ struct ImGuiPlatformIO
|
|||||||
|
|
||||||
// Written by some backends during ImGui_ImplXXXX_RenderDrawData() call to point backend_specific ImGui_ImplXXXX_RenderState* structure.
|
// Written by some backends during ImGui_ImplXXXX_RenderDrawData() call to point backend_specific ImGui_ImplXXXX_RenderState* structure.
|
||||||
void* Renderer_RenderState;
|
void* Renderer_RenderState;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
// Output
|
||||||
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Textures list (the list is updated by calling ImGui::EndFrame or ImGui::Render)
|
||||||
|
ImVector<ImTextureData*> Textures; // Texture list (most often Textures.Size == 1).
|
||||||
};
|
};
|
||||||
|
|
||||||
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. Handler is called during EndFrame().
|
// (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. Handler is called during EndFrame().
|
||||||
|
|||||||
Reference in New Issue
Block a user