mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Fonts: marked ImFontAtlas::Build() as obsolete
This commit is contained in:
parent
4399599de9
commit
df8450d928
4 changed files with 28 additions and 24 deletions
|
|
@ -5243,9 +5243,9 @@ void ImGui::NewFrame()
|
||||||
// Check that font atlas was built or backend support texture reload in which case we can build now
|
// Check that font atlas was built or backend support texture reload in which case we can build now
|
||||||
ImFontAtlas* atlas = g.IO.Fonts;
|
ImFontAtlas* atlas = g.IO.Fonts;
|
||||||
if (!atlas->TexIsBuilt && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures))
|
if (!atlas->TexIsBuilt && (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures))
|
||||||
atlas->Build();
|
ImFontAtlasBuildMain(atlas);
|
||||||
else // Legacy backend
|
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
|
// Check and assert for various common IO and Configuration mistakes
|
||||||
ErrorCheckNewFrameSanityChecks();
|
ErrorCheckNewFrameSanityChecks();
|
||||||
|
|
|
||||||
6
imgui.h
6
imgui.h
|
|
@ -3530,15 +3530,15 @@ struct ImFontAtlas
|
||||||
IMGUI_API void ClearFonts(); // [OBSOLETE] Clear input+output font data (same as ClearInputData() + glyphs storage, UV coordinates).
|
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 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.
|
// 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().
|
// 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)
|
// 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
|
// 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.
|
// 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 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 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
|
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.
|
void SetTexID(ImTextureID id) { TexRef._TexData = NULL; TexRef._TexID = id; } // Called by legacy backends.
|
||||||
|
|
|
||||||
|
|
@ -2466,9 +2466,9 @@ void ImTextureData::DestroyPixels()
|
||||||
// - ImFontAtlasTextureBlockCopy()
|
// - ImFontAtlasTextureBlockCopy()
|
||||||
// - ImFontAtlasTextureBlockQueueUpload()
|
// - ImFontAtlasTextureBlockQueueUpload()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
// - ImFontAtlas::Build() [legacy]
|
||||||
// - ImFontAtlas::GetTexDataAsAlpha8() [legacy]
|
// - ImFontAtlas::GetTexDataAsAlpha8() [legacy]
|
||||||
// - ImFontAtlas::GetTexDataAsRGBA32() [legacy]
|
// - ImFontAtlas::GetTexDataAsRGBA32() [legacy]
|
||||||
// - ImFontAtlas::Build()
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// - ImFontAtlas::AddFont()
|
// - ImFontAtlas::AddFont()
|
||||||
// - ImFontAtlas::AddFontDefault()
|
// - ImFontAtlas::AddFontDefault()
|
||||||
|
|
@ -2872,6 +2872,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);
|
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
|
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||||
|
|
||||||
ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg)
|
||||||
|
|
@ -3136,31 +3142,28 @@ bool ImFontAtlasGetMouseCursorTexData(ImFontAtlas* atlas, ImGuiMouseCursor curso
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImFontAtlas::Build()
|
void ImFontAtlasBuildMain(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
|
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
|
||||||
|
if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat)
|
||||||
if (TexData && TexData->Format != TexDesiredFormat)
|
|
||||||
{
|
{
|
||||||
ImVec2i new_tex_size = ImFontAtlasBuildGetTextureSizeEstimate(this);
|
ImVec2i new_tex_size = ImFontAtlasBuildGetTextureSizeEstimate(atlas);
|
||||||
ImFontAtlasBuildDestroy(this);
|
ImFontAtlasBuildDestroy(atlas);
|
||||||
ImFontAtlasBuildAddTexture(this, new_tex_size.x, new_tex_size.y);
|
ImFontAtlasBuildAddTexture(atlas, new_tex_size.x, new_tex_size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Builder == NULL)
|
if (atlas->Builder == NULL)
|
||||||
ImFontAtlasBuildInit(this);
|
ImFontAtlasBuildInit(atlas);
|
||||||
|
|
||||||
// Default font is none are specified
|
// Default font is none are specified
|
||||||
if (Sources.Size == 0)
|
if (atlas->Sources.Size == 0)
|
||||||
AddFontDefault();
|
atlas->AddFontDefault();
|
||||||
|
|
||||||
// [LEGACY] For backends not supporting RendererHasTextures: preload all glyphs
|
// [LEGACY] For backends not supporting RendererHasTexUpdates: preload all glyphs
|
||||||
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(this);
|
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);
|
||||||
if (DrawListSharedData && DrawListSharedData->RendererHasTextures == false) // ~ImGuiBackendFlags_RendererHasTextures
|
if (atlas->DrawListSharedData && atlas->DrawListSharedData->RendererHasTextures == false) // ~ImGuiBackendFlags_RendererHasTextures
|
||||||
ImFontAtlasBuildPreloadAllGlyphRanges(this);
|
ImFontAtlasBuildPreloadAllGlyphRanges(atlas);
|
||||||
TexIsBuilt = true;
|
atlas->TexIsBuilt = true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlasBuildGetOversampleFactors(ImFontConfig* src, int* out_oversample_h, int* out_oversample_v)
|
void ImFontAtlasBuildGetOversampleFactors(ImFontConfig* src, int* out_oversample_h, int* out_oversample_v)
|
||||||
|
|
|
||||||
|
|
@ -3705,6 +3705,7 @@ IMGUI_API void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas,
|
||||||
IMGUI_API void ImFontAtlasBuildUpdatePointers(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 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 ImFontAtlasBuildInit(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildDestroy(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildDestroy(ImFontAtlas* atlas);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue