Skip to content

Commit

Permalink
Function to control whether final rendering is performed (useful for …
Browse files Browse the repository at this point in the history
…extension-netimgui) (#35)
  • Loading branch information
dri-richard authored Nov 1, 2023
1 parent 263937d commit 09530e5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
9 changes: 9 additions & 0 deletions imgui/api/imgui.script_api
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,15 @@
- name: sizey
type: number

#*****************************************************************************************************

- name: set_rendering_enabled
type: function

parameters:
- name: enabled
type: boolean

#*****************************************************************************************************
#***** INPUT *****************************************************************************************
#*****************************************************************************************************
Expand Down
19 changes: 16 additions & 3 deletions imgui/src/extension_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static char* g_imgui_TextBuffer = 0;
static dmArray<ImFont*> g_imgui_Fonts;
static dmArray<ImgObject> g_imgui_Images;
static bool g_VerifyGraphicsCalls = false;

static bool g_RenderingEnabled = true;


static void imgui_ClearGLError()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 -----------------
// ----------------------------
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 09530e5

Please sign in to comment.