diff --git a/imgui/api/imgui.script_api b/imgui/api/imgui.script_api index e4e3304..2e2aa54 100644 --- a/imgui/api/imgui.script_api +++ b/imgui/api/imgui.script_api @@ -1204,6 +1204,15 @@ - name: sizey type: number +#***************************************************************************************************** + + - name: set_rendering_enabled + type: function + + parameters: + - name: enabled + type: boolean + #***************************************************************************************************** #***** INPUT ***************************************************************************************** #***************************************************************************************************** diff --git a/imgui/src/extension_imgui.cpp b/imgui/src/extension_imgui.cpp index 481c661..0a1b388 100644 --- a/imgui/src/extension_imgui.cpp +++ b/imgui/src/extension_imgui.cpp @@ -43,7 +43,7 @@ static char* g_imgui_TextBuffer = 0; static dmArray g_imgui_Fonts; static dmArray g_imgui_Images; static bool g_VerifyGraphicsCalls = false; - +static bool g_RenderingEnabled = true; static void imgui_ClearGLError() @@ -1896,7 +1896,12 @@ static dmExtension::Result imgui_Draw(dmExtension::Params* params) { imgui_NewFrame(); ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + + if (g_RenderingEnabled) + { + ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); + } + imgui_ClearGLError(); g_imgui_NewFrame = false; @@ -1960,6 +1965,14 @@ static int imgui_DrawProgressBar(lua_State* L) return 0; } +static int imgui_SetRenderingEnabled(lua_State* L) +{ + DM_LUA_STACK_CHECK(L, 0); + bool enabled = lua_toboolean(L, 1); + g_RenderingEnabled = enabled; + return 0; +} + // ---------------------------- // ----- INPUT CAPTURE ----------------- // ---------------------------- @@ -2196,7 +2209,7 @@ static const luaL_reg Module_methods[] = {"draw_rect_filled", imgui_DrawRectFilled}, {"draw_line", imgui_DrawLine}, {"draw_progress", imgui_DrawProgressBar}, - + {"set_rendering_enabled", imgui_SetRenderingEnabled}, {"demo", imgui_Demo}, {"set_mouse_input", imgui_SetMouseInput},