Pārlūkot izejas kodu

imgui: allow a client application to invalidate fonts.

legacy
Sam Hocevar pirms 5 gadiem
vecāks
revīzija
8eaf5e1a0f
2 mainītis faili ar 20 papildinājumiem un 9 dzēšanām
  1. +18
    -9
      src/lolimgui.cpp
  2. +2
    -0
      src/lolimgui.h

+ 18
- 9
src/lolimgui.cpp Parādīt failu

@@ -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 Parādīt failu

@@ -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);


Notiek ielāde…
Atcelt
Saglabāt