MCPcopy Create free account
hub / github.com/SFML/imgui-sfml / UpdateFontTexture

Function UpdateFontTexture

imgui-SFML.cpp:628–653  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626}
627
628bool UpdateFontTexture()
629{
630 assert(s_currWindowCtx);
631
632 ImGuiIO& io = ImGui::GetIO();
633 unsigned char* pixels = nullptr;
634 int width = 0;
635 int height = 0;
636
637 io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
638
639 sf::Texture newTexture;
640 if (!newTexture.resize(sf::Vector2u(sf::Vector2(width, height))))
641 {
642 return false;
643 }
644
645 newTexture.update(pixels);
646
647 ImTextureID texID = convertGLTextureHandleToImTextureID(newTexture.getNativeHandle());
648 io.Fonts->SetTexID(texID);
649
650 s_currWindowCtx->fontTexture = std::move(newTexture);
651
652 return true;
653}
654
655std::optional<sf::Texture>& GetFontTexture()
656{

Callers 1

InitFunction · 0.85

Tested by

no test coverage detected