From 0224d29a3576b267e0dc42976ed8d83dad1ebd17 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 15 Jul 2015 09:05:17 -0600 Subject: [PATCH] Examples: comments. --- examples/allegro5_example/main.cpp | 20 ++++++++++++++------ examples/directx11_example/main.cpp | 10 +++++++++- examples/directx9_example/main.cpp | 13 ++++++++++--- examples/opengl3_example/main.cpp | 10 +++++++++- examples/opengl_example/main.cpp | 10 +++++++++- examples/sdl_opengl_example/main.cpp | 20 ++++++++++++++------ 6 files changed, 65 insertions(+), 18 deletions(-) diff --git a/examples/allegro5_example/main.cpp b/examples/allegro5_example/main.cpp index 1898a579..9adaa7d2 100644 --- a/examples/allegro5_example/main.cpp +++ b/examples/allegro5_example/main.cpp @@ -23,13 +23,21 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplA5_Init(display); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); - //ImFont* my_font0 = io.Fonts->AddFontDefault(); - //ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); - //ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1; - //ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1; - //ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese()); + //io.Fonts->AddFontDefault(); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); + //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); bool show_test_window = true; bool show_another_window = false; diff --git a/examples/directx11_example/main.cpp b/examples/directx11_example/main.cpp index c04cd847..59213bc7 100644 --- a/examples/directx11_example/main.cpp +++ b/examples/directx11_example/main.cpp @@ -149,14 +149,22 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplDX11_Init(hwnd, g_pd3dDevice, g_pd3dDeviceContext); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); + bool show_test_window = true; bool show_another_window = false; ImVec4 clear_col = ImColor(114, 144, 154); diff --git a/examples/directx9_example/main.cpp b/examples/directx9_example/main.cpp index f73450d3..cf83aed3 100644 --- a/examples/directx9_example/main.cpp +++ b/examples/directx9_example/main.cpp @@ -73,16 +73,21 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplDX9_Init(hwnd, g_pd3dDevice); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); - ShowWindow(hwnd, SW_SHOWDEFAULT); - UpdateWindow(hwnd); + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); bool show_test_window = true; bool show_another_window = false; @@ -91,6 +96,8 @@ int main(int, char**) // Main loop MSG msg; ZeroMemory(&msg, sizeof(msg)); + ShowWindow(hwnd, SW_SHOWDEFAULT); + UpdateWindow(hwnd); while (msg.message != WM_QUIT) { if (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) diff --git a/examples/opengl3_example/main.cpp b/examples/opengl3_example/main.cpp index 3dcedd6b..5e9c8875 100644 --- a/examples/opengl3_example/main.cpp +++ b/examples/opengl3_example/main.cpp @@ -29,14 +29,22 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplGlfwGL3_Init(window, true); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); + bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/opengl_example/main.cpp b/examples/opengl_example/main.cpp index 194bd66d..503ea36c 100644 --- a/examples/opengl_example/main.cpp +++ b/examples/opengl_example/main.cpp @@ -21,14 +21,22 @@ int main(int, char**) // Setup ImGui binding ImGui_ImplGlfw_Init(window, true); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); //io.Fonts->AddFontDefault(); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); + bool show_test_window = true; bool show_another_window = false; ImVec4 clear_color = ImColor(114, 144, 154); diff --git a/examples/sdl_opengl_example/main.cpp b/examples/sdl_opengl_example/main.cpp index 3c8807f4..1233044f 100644 --- a/examples/sdl_opengl_example/main.cpp +++ b/examples/sdl_opengl_example/main.cpp @@ -25,13 +25,21 @@ int SDL_main(int, char**) // Setup ImGui binding ImGui_ImplSdl_Init(window); + + // Load Fonts + // (see extra_fonts/README.txt for more details) //ImGuiIO& io = ImGui::GetIO(); - //ImFont* my_font0 = io.Fonts->AddFontDefault(); - //ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); - //ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f); - //ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1; - //ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1; - //ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese()); + //io.Fonts->AddFontDefault(); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); + //io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, NULL, io.Fonts->GetGlyphRangesJapanese()); + + // Merge glyphs from multiple fonts into one (e.g. combine default font with another with Chinese glyphs, or add icons) + //ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; + //ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true; + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 18.0f); + //io.Fonts->AddFontFromFileTTF("../../extra_fonts/fontawesome-webfont.ttf", 18.0f, &icons_config, icons_ranges); bool show_test_window = true; bool show_another_window = false;