1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-18 18:46:13 +01:00

OpenGL example: minor tweak for non-default font.

This commit is contained in:
ocornut 2014-09-26 01:04:31 +01:00
parent b756510f21
commit 22fe7f23b1

View File

@ -204,12 +204,16 @@ void InitImGui()
ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size); ImGui::GetDefaultFontData(NULL, NULL, &png_data, &png_size);
int tex_x, tex_y, tex_comp; int tex_x, tex_y, tex_comp;
void* tex_data = stbi_load_from_memory((const unsigned char*)png_data, (int)png_size, &tex_x, &tex_y, &tex_comp, 0); void* tex_data = stbi_load_from_memory((const unsigned char*)png_data, (int)png_size, &tex_x, &tex_y, &tex_comp, 0);
IM_ASSERT(tex_data != NULL);
#else #else
// Custom font from filesystem // Custom font from filesystem
io.Font = new ImBitmapFont(); io.Font = new ImBitmapFont();
io.Font->LoadFromFile("../../extra_fonts/arial_unicode_ms_18_CJK.fnt"); io.Font->LoadFromFile("../../extra_fonts/mplus-2m-medium_18.fnt");
IM_ASSERT(io.Font->IsLoaded());
int tex_x, tex_y, tex_comp; int tex_x, tex_y, tex_comp;
void* tex_data = stbi_load("../../extra_fonts/arial_unicode_ms_18_CJK.png", &tex_x, &tex_y, &tex_comp, 4); void* tex_data = stbi_load("../../extra_fonts/mplus-2m-medium_18.png", &tex_x, &tex_y, &tex_comp, 0);
IM_ASSERT(tex_data != NULL);
// Automatically find white pixel from the texture we just loaded // Automatically find white pixel from the texture we just loaded
// (io.FontTexUvForWhite needs to contains UV coordinates pointing to a white pixel in order to render solid objects) // (io.FontTexUvForWhite needs to contains UV coordinates pointing to a white pixel in order to render solid objects)