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

View File

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