2021-05-24 17:54:18 +08:00
|
|
|
# ImGuiEXT of adxe
|
2020-09-05 17:10:09 +08:00
|
|
|
Sync from https://github.com/Xrysnow/cocos2d-x-imgui and do a little changes
|
|
|
|
|
|
|
|
## Improvements
|
2020-09-08 15:15:25 +08:00
|
|
|
* Simplify API, use add/remove renderLoop present ImGui GUI widgets
|
2020-09-05 17:10:09 +08:00
|
|
|
* 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 ```ImGuiEXT``` instance support
|
2020-09-08 15:15:25 +08:00
|
|
|
* Use ```FOURCC``` for key of ImGui render loop
|
|
|
|
* Add dpi scale support, use ```ImGuiEXT::getInstance()->scaleAllByDPI(1.0);```
|
|
|
|
* Easy font manager, stable API ```addFont,removeFont,clearFonts``` to manage ImGui fonts, with ImGui API, very hard to do correctly.
|
2020-09-05 17:10:09 +08:00
|
|
|
|
|
|
|
## How to use
|
|
|
|
```cpp
|
|
|
|
#include "ImGuiEXT/CCImGuiEXT.h"
|
|
|
|
USING_NS_CC;
|
|
|
|
USING_NS_CC_EXT;
|
|
|
|
|
|
|
|
class GameScene : public Scene {
|
|
|
|
public:
|
|
|
|
void onEnter() override
|
|
|
|
{
|
2020-09-08 17:06:12 +08:00
|
|
|
Scene::onEnter();
|
2020-09-08 13:44:59 +08:00
|
|
|
ImGuiEXT::getInstance()->addRenderLoop("#im01", CC_CALLBACK_0(GameScene::onImGuiDraw, this), this);
|
2020-09-05 17:10:09 +08:00
|
|
|
}
|
|
|
|
void onExit() override
|
|
|
|
{
|
2020-09-08 17:06:12 +08:00
|
|
|
Scene::onExit();
|
2020-09-05 17:10:09 +08:00
|
|
|
ImGuiEXT::getInstance()->removeRenderLoop("#im01");
|
|
|
|
}
|
|
|
|
void onImGuiDraw()
|
|
|
|
{
|
|
|
|
ImGui::Begin("window");
|
|
|
|
ImGui::Text("FPS=%.1f", 1.f / ImGui::GetIO().DeltaTime);
|
|
|
|
ImGui::End();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 15:07:16 +08:00
|
|
|
```
|
|
|
|
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 it for macOS
|
2020-09-08 18:21:41 +08:00
|
|
|
|
|
|
|
## Other resources of ImGui
|
|
|
|
* https://github.com/ocornut/imgui/wiki/Bindings
|
|
|
|
* https://github.com/CedricGuillemet/ImGuizmo
|