axmol/extensions/ImGui
halx99 fc669c31fe Fix android ImGUI font Render
Update imgui_impl_ax glfw to match with ImGui 1.89.8-docking
2023-09-04 20:03:01 +08:00
..
imgui Merge: 41714a04fd 2631c8405b 2023-09-02 19:56:50 +08:00
shaders Merge: 41714a04fd 2631c8405b 2023-09-02 19:56:50 +08:00
CMakeLists.txt Merge: 41714a04fd 2631c8405b 2023-09-02 19:56:50 +08:00
ImGuiPresenter.cpp Fix ImGui PC platform macro detection 2023-09-03 13:22:40 +08:00
ImGuiPresenter.h Enable ImGui for Android (#909) 2022-10-10 03:53:24 +08:00
LICENSE Renaming extension ImGuiEXT to ImGui 2022-02-25 19:03:09 +08:00
README.md Final migrate (#876) 2022-10-01 16:24:52 +08:00
imgui_impl_ax.cpp Fix android ImGUI font Render 2023-09-04 20:03:01 +08:00
imgui_impl_ax.h Enable ImGui for Android (#909) 2022-10-10 03:53:24 +08:00
imgui_impl_ax_android.cpp Fix android ImGUI font Render 2023-09-04 20:03:01 +08:00
imgui_impl_ax_android.h Remove CC prefix from code file name (#1230) 2023-06-11 13:08:08 +08:00

README.md

The ImGui extension for axmol

Sync from https://github.com/Xrysnow/cocos2d-x-imgui and do a little changes

Improvements

  • Simplify API, use add/remove renderLoop present ImGui GUI widgets
  • Optimize call pipeline flow, support add/remove Node to Scene at ImGui render loop without container iterator damage
  • Calculate deltaTime at ImGui_ImplCocos2dx_NewFrame to avoid error when cc.Director paused
  • Refine Init/Shutdown, Restore all callbacks for glfw to solve recreate ImGuiPresenter instance support
  • Use FOURCC for key of ImGui render loop
  • Add dpi scale support, use ImGuiPresenter::getInstance()->scaleAllByDPI(1.0);
  • Easy font manager, stable API addFont,removeFont,clearFonts to manage ImGui fonts, with ImGui API, very hard to do correctly.

How to use

#include "ImGui/ImGuiPresenter.h"
USING_NS_AX;
USING_NS_AX_EXT;

class GameScene : public Scene {
public:
    void onEnter() override
    {
        Scene::onEnter();
        ImGuiPresenter::getInstance()->addFont(R"(C:\Windows\Fonts\msyh.ttc)");
        /* For Simplified Chinese support, please use:
        ImGuiPresenter::getInstance()->addFont(R"(C:\Windows\Fonts\msyh.ttc)", ImGuiPresenter::DEFAULT_FONT_SIZE,
                                           ImGuiPresenter::CHS_GLYPH_RANGE::GENERAL);
        */
        ImGuiPresenter::getInstance()->addRenderLoop("#im01", AX_CALLBACK_0(GameScene::onImGuiDraw, this), this);
    }
    void onExit() override
    {
        Scene::onExit();
        ImGuiPresenter::getInstance()->removeRenderLoop("#im01");
    }
    void onImGuiDraw()
    {
        ImGui::Begin("window");
        ImGui::Text("FPS=%.1f", 1.f / ImGui::GetIO().DeltaTime);
        ImGui::End();
    }
}

More about use imgui widgets, please see: https://github.com/ocornut/imgui

Tested devices

  • win32
  • macOS

Known issues

  • Can't enable muti-viewports on macOS, so we disable this feature for macOS.

Other resources of ImGui