mirror of
https://github.com/ocornut/imgui.git
synced 2025-04-06 22:15:07 +00:00
WIP - Marked ImFontAtlas::Build() as obsolete
This commit is contained in:
parent
7b3f2c4857
commit
a9ae6b764f
4 changed files with 28 additions and 24 deletions
|
@ -5400,9 +5400,9 @@ void ImGui::NewFrame()
|
|||
// Check that font atlas was built or backend support texture reload in which case we can build now
|
||||
ImFontAtlas* atlas = g.IO.Fonts;
|
||||
if (!atlas->TexIsBuilt && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures))
|
||||
atlas->Build();
|
||||
ImFontAtlasBuildMain(atlas);
|
||||
else // Legacy backend
|
||||
IM_ASSERT(atlas->TexIsBuilt && "Font Atlas not built! Make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8()");
|
||||
IM_ASSERT(atlas->TexIsBuilt && "Backend does not support ImGuiBackendFlags_RendererHasTexUpdates, and font atlas is not built! Update backend OR make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8().");
|
||||
|
||||
// Check and assert for various common IO and Configuration mistakes
|
||||
g.ConfigFlagsLastFrame = g.ConfigFlagsCurrFrame;
|
||||
|
|
6
imgui.h
6
imgui.h
|
@ -3627,15 +3627,15 @@ struct ImFontAtlas
|
|||
IMGUI_API void ClearFonts(); // [OBSOLETE] Clear input+output font data (same as ClearInputData() + glyphs storage, UV coordinates).
|
||||
IMGUI_API void ClearTexData(); // [OBSOLETE] Clear output texture data (CPU side). Saves RAM once the texture has been copied to graphics memory.
|
||||
|
||||
IMGUI_API void BuildGrowTexture();
|
||||
IMGUI_API void BuildCompactTexture();
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
// Build atlas, retrieve pixel data.
|
||||
// User is in charge of copying the pixels into graphics memory (e.g. create a texture with your engine). Then store your texture handle with SetTexID().
|
||||
// The pitch is always = Width * BytesPerPixels (1 or 4)
|
||||
// Building in RGBA32 format is provided for convenience and compatibility, but note that unless you manually manipulate or copy color data into
|
||||
// the texture (e.g. when using the AddCustomRect*** api), then the RGB pixels emitted will always be white (~75% of memory/bandwidth waste.
|
||||
IMGUI_API bool Build(); // Build pixels data. This is called automatically for you by the GetTexData*** functions.
|
||||
IMGUI_API void BuildGrowTexture();
|
||||
IMGUI_API void BuildCompactTexture();
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
IMGUI_API void GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 1 byte per-pixel
|
||||
IMGUI_API void GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel = NULL); // 4 bytes-per-pixel
|
||||
void SetTexID(ImTextureID id) { TexRef._TexData = NULL; TexRef._TexID = id; } // Called by legacy backends.
|
||||
|
|
|
@ -2468,9 +2468,9 @@ void ImTextureData::DestroyPixels()
|
|||
// - ImFontAtlasTextureBlockCopy()
|
||||
// - ImFontAtlasTextureBlockQueueUpload()
|
||||
//-----------------------------------------------------------------------------
|
||||
// - ImFontAtlas::Build() [legacy]
|
||||
// - ImFontAtlas::GetTexDataAsAlpha8() [legacy]
|
||||
// - ImFontAtlas::GetTexDataAsRGBA32() [legacy]
|
||||
// - ImFontAtlas::Build()
|
||||
//-----------------------------------------------------------------------------
|
||||
// - ImFontAtlas::AddFont()
|
||||
// - ImFontAtlas::AddFontDefault()
|
||||
|
@ -2875,6 +2875,12 @@ void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width,
|
|||
{
|
||||
GetTexDataAsFormat(this, ImTextureFormat_RGBA32, out_pixels, out_width, out_height, out_bytes_per_pixel);
|
||||
}
|
||||
|
||||
bool ImFontAtlas::Build()
|
||||
{
|
||||
ImFontAtlasBuildMain(this);
|
||||
return true;
|
||||
}
|
||||
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
|
||||
ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||
|
@ -3139,31 +3145,28 @@ bool ImFontAtlasGetMouseCursorTexData(ImFontAtlas* atlas, ImGuiMouseCursor curso
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ImFontAtlas::Build()
|
||||
void ImFontAtlasBuildMain(ImFontAtlas* atlas)
|
||||
{
|
||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
|
||||
|
||||
if (TexData && TexData->Format != TexDesiredFormat)
|
||||
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
|
||||
if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat)
|
||||
{
|
||||
ImVec2i new_tex_size = ImFontAtlasBuildGetTextureSizeEstimate(this);
|
||||
ImFontAtlasBuildDestroy(this);
|
||||
ImFontAtlasBuildAddTexture(this, new_tex_size.x, new_tex_size.y);
|
||||
ImVec2i new_tex_size = ImFontAtlasBuildGetTextureSizeEstimate(atlas);
|
||||
ImFontAtlasBuildDestroy(atlas);
|
||||
ImFontAtlasBuildAddTexture(atlas, new_tex_size.x, new_tex_size.y);
|
||||
}
|
||||
|
||||
if (Builder == NULL)
|
||||
ImFontAtlasBuildInit(this);
|
||||
if (atlas->Builder == NULL)
|
||||
ImFontAtlasBuildInit(atlas);
|
||||
|
||||
// Default font is none are specified
|
||||
if (Sources.Size == 0)
|
||||
AddFontDefault();
|
||||
if (atlas->Sources.Size == 0)
|
||||
atlas->AddFontDefault();
|
||||
|
||||
// [LEGACY] For backends not supporting RendererHasTextures: preload all glyphs
|
||||
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(this);
|
||||
if (DrawListSharedData && DrawListSharedData->RendererHasTextures == false) // ~ImGuiBackendFlags_RendererHasTextures
|
||||
ImFontAtlasBuildPreloadAllGlyphRanges(this);
|
||||
TexIsBuilt = true;
|
||||
|
||||
return true;
|
||||
// [LEGACY] For backends not supporting RendererHasTexUpdates: preload all glyphs
|
||||
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);
|
||||
if (atlas->DrawListSharedData && atlas->DrawListSharedData->RendererHasTextures == false) // ~ImGuiBackendFlags_RendererHasTextures
|
||||
ImFontAtlasBuildPreloadAllGlyphRanges(atlas);
|
||||
atlas->TexIsBuilt = true;
|
||||
}
|
||||
|
||||
void ImFontAtlasBuildGetOversampleFactors(ImFontConfig* src, int* out_oversample_h, int* out_oversample_v)
|
||||
|
|
|
@ -3991,6 +3991,7 @@ IMGUI_API void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas,
|
|||
IMGUI_API void ImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char);
|
||||
|
||||
IMGUI_API void ImFontAtlasBuildMain(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
||||
IMGUI_API void ImFontAtlasBuildDestroy(ImFontAtlas* atlas);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue