Add ImGuiEXT::end to end game

This commit is contained in:
halx99 2020-09-10 17:53:17 +08:00
parent 41d7f571ef
commit 165b588a10
2 changed files with 14 additions and 1 deletions

View File

@ -257,11 +257,21 @@ void ImGuiEXT::clearFonts()
// if(drawData) drawData->Clear();
}
void ImGuiEXT::end()
{
_purgeNextLoop = true;
}
/*
* begin ImGui frame and draw ImGui stubs
*/
void ImGuiEXT::beginFrame()
{ // drived by event Director::EVENT_BEFORE_DRAW from engine mainLoop
if(_purgeNextLoop)
{
Director::getInstance()->end();
return;
}
if (!_renderPiplines.empty()) {
// create frame
ImGui_ImplCocos2dx_NewFrame();
@ -299,7 +309,6 @@ void ImGuiEXT::endFrame() {
void ImGuiEXT::update()
{
// clear things from last frame
usedCCRefIdMap.clear();
usedCCRef.clear();

View File

@ -66,6 +66,8 @@ public:
/// <param name="id">FOURCC starts with '#', such as "#abcd"</id>
void removeRenderLoop(const std::string& id);
void end();
// imgui helper
void image(
Texture2D* tex,
@ -168,6 +170,8 @@ private:
};
std::unordered_map<std::string, FontInfo> _fontsInfoMap;
bool _purgeNextLoop = false;
};
NS_CC_EXT_END