Explorar el Código

imgui: allow a client application to invalidate fonts.

legacy
Sam Hocevar hace 6 años
padre
commit
8eaf5e1a0f
Se han modificado 2 ficheros con 20 adiciones y 9 borrados
  1. +18
    -9
      src/lolimgui.cpp
  2. +2
    -0
      src/lolimgui.h

+ 18
- 9
src/lolimgui.cpp Ver fichero

@@ -181,6 +181,23 @@ const char* LolImGui::GetClipboardCallback(void *data)
return clipboard->c_str(); 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) void LolImGui::tick_game(float seconds)
{ {
@@ -191,15 +208,7 @@ void LolImGui::tick_game(float seconds)
// Init Texture // Init Texture
if (!m_font) 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 // Texture has been created


+ 2
- 0
src/lolimgui.h Ver fichero

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


static void refresh_fonts();

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


Cargando…
Cancelar
Guardar