Quellcode durchsuchen

imgui: allow a client application to invalidate fonts.

legacy
Sam Hocevar vor 5 Jahren
Ursprung
Commit
8eaf5e1a0f
2 geänderte Dateien mit 20 neuen und 9 gelöschten Zeilen
  1. +18
    -9
      src/lolimgui.cpp
  2. +2
    -0
      src/lolimgui.h

+ 18
- 9
src/lolimgui.cpp Datei anzeigen

@@ -181,6 +181,23 @@ const char* LolImGui::GetClipboardCallback(void *data)
return clipboard->c_str();
}

void LolImGui::refresh_fonts()
{
if (g_lolimgui->m_font)
Ticker::Unref(g_lolimgui->m_font);

// Build texture
unsigned char* pixels;
ivec2 size;
ImGuiIO& io = ImGui::GetIO();
io.Fonts->GetTexDataAsRGBA32(&pixels, &size.x, &size.y);

Image* image = new Image();
image->Copy(pixels, size, PixelFormat::RGBA_8);

Ticker::Ref(g_lolimgui->m_font = new TextureImage("", image));
}

//-----------------------------------------------------------------------------
void LolImGui::tick_game(float seconds)
{
@@ -191,15 +208,7 @@ void LolImGui::tick_game(float seconds)
// Init Texture
if (!m_font)
{
// Build texture
unsigned char* pixels;
ivec2 size;
io.Fonts->GetTexDataAsRGBA32(&pixels, &size.x, &size.y);

Image* image = new Image();
image->Copy(pixels, size, PixelFormat::RGBA_8);

Ticker::Ref(m_font = new TextureImage("", image));
refresh_fonts();
}

// Texture has been created


+ 2
- 0
src/lolimgui.h Datei anzeigen

@@ -160,6 +160,8 @@ public:
//-------------------------------------------------------------------------
static std::string GetClipboard();

static void refresh_fonts();

protected:
virtual void tick_game(float seconds);
virtual void tick_draw(float seconds, Scene &scene);


Laden…
Abbrechen
Speichern