Skip to content

Commit cf2daf3

Browse files
committed
Backends: Cleanup, removed unnecessary create/destroy wrappers. Fix allegro5 backend + use same code as other backend.
+ Update gallery links (#4280)
1 parent 6792e1a commit cf2daf3

13 files changed

+129
-121
lines changed

backends/imgui_impl_allegro5.cpp

+15-18
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ struct ImGui_ImplAllegro5_Data
6767
ImGui_ImplAllegro5_Data() { memset(this, 0, sizeof(*this)); }
6868
};
6969

70-
// Wrapping access to backend data (to facilitate multiple-contexts stored in io.BackendPlatformUserData)
71-
static ImGui_ImplAllegro5_Data* g_Data;
72-
static ImGui_ImplAllegro5_Data* ImGui_ImplAllegro5_CreateBackendData() { IM_ASSERT(g_Data == NULL); g_Data = IM_NEW(ImGui_ImplAllegro5_Data); return g_Data; }
73-
static ImGui_ImplAllegro5_Data* ImGui_ImplAllegro5_GetBackendData() { return ImGui::GetCurrentContext() != NULL ? g_Data : NULL; }
74-
static void ImGui_ImplAllegro5_DestroyBackendData() { IM_DELETE(g_Data); g_Data = NULL; }
70+
// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
71+
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
72+
// FIXME: multi-context support is not well tested and probably dysfunctional in this backend.
73+
static ImGui_ImplAllegro5_Data* ImGui_ImplAllegro5_GetBackendData() { return ImGui::GetCurrentContext() ? (ImGui_ImplAllegro5_Data*)ImGui::GetIO().BackendPlatformUserData : NULL; }
7574

7675
struct ImDrawVertAllegro
7776
{
@@ -274,13 +273,13 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
274273
ImGuiIO& io = ImGui::GetIO();
275274
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
276275

277-
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_CreateBackendData();
278-
bd->Display = display;
279-
280276
// Setup backend capabilities flags
281-
io.BackendRendererUserData = (void*)bd;
282-
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
277+
ImGui_ImplAllegro5_Data* bd = IM_NEW(ImGui_ImplAllegro5_Data)();
278+
io.BackendPlatformUserData = (void*)bd;
283279
io.BackendPlatformName = io.BackendRendererName = "imgui_impl_allegro5";
280+
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
281+
282+
bd->Display = display;
284283

285284
// Create custom vertex declaration.
286285
// Unfortunately Allegro doesn't support 32-bit packed colors so we have to convert them to 4 floats.
@@ -329,20 +328,18 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
329328

330329
void ImGui_ImplAllegro5_Shutdown()
331330
{
331+
ImGuiIO& io = ImGui::GetIO();
332332
ImGui_ImplAllegro5_Data* bd = ImGui_ImplAllegro5_GetBackendData();
333-
ImGui_ImplAllegro5_InvalidateDeviceObjects();
334-
335-
bd->Display = NULL;
336-
bd->Time = 0.0;
337333

334+
ImGui_ImplAllegro5_InvalidateDeviceObjects();
338335
if (bd->VertexDecl)
339336
al_destroy_vertex_decl(bd->VertexDecl);
340-
bd->VertexDecl = NULL;
341-
342337
if (bd->ClipboardTextData)
343338
al_free(bd->ClipboardTextData);
344-
bd->ClipboardTextData = NULL;
345-
ImGui_ImplAllegro5_DestroyBackendData();
339+
340+
io.BackendPlatformUserData = NULL;
341+
io.BackendPlatformName = io.BackendRendererName = NULL;
342+
IM_DELETE(bd);
346343
}
347344

348345
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.

backends/imgui_impl_dx10.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,18 @@ struct ImGui_ImplDX10_Data
6262
ImGui_ImplDX10_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
6363
};
6464

65-
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
66-
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
67-
static ImGui_ImplDX10_Data* ImGui_ImplDX10_CreateBackendData() { return IM_NEW(ImGui_ImplDX10_Data)(); }
68-
static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData() { return (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData; }
69-
static void ImGui_ImplDX10_DestroyBackendData() { IM_DELETE(ImGui_ImplDX10_GetBackendData()); }
70-
7165
struct VERTEX_CONSTANT_BUFFER
7266
{
7367
float mvp[4][4];
7468
};
7569

70+
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
71+
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
72+
static ImGui_ImplDX10_Data* ImGui_ImplDX10_GetBackendData()
73+
{
74+
return ImGui::GetCurrentContext() ? (ImGui_ImplDX10_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
75+
}
76+
7677
// Functions
7778
static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device* ctx)
7879
{
@@ -524,7 +525,7 @@ bool ImGui_ImplDX10_Init(ID3D10Device* device)
524525
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
525526

526527
// Setup backend capabilities flags
527-
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_CreateBackendData();
528+
ImGui_ImplDX10_Data* bd = IM_NEW(ImGui_ImplDX10_Data)();
528529
io.BackendRendererUserData = (void*)bd;
529530
io.BackendRendererName = "imgui_impl_dx10";
530531
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
@@ -553,11 +554,11 @@ void ImGui_ImplDX10_Shutdown()
553554
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
554555

555556
ImGui_ImplDX10_InvalidateDeviceObjects();
556-
if (bd->pFactory) { bd->pFactory->Release(); bd->pFactory = NULL; }
557-
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); bd->pd3dDevice = NULL; }
557+
if (bd->pFactory) { bd->pFactory->Release(); }
558+
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
558559
io.BackendRendererName = NULL;
559560
io.BackendRendererUserData = NULL;
560-
ImGui_ImplDX10_DestroyBackendData();
561+
IM_DELETE(bd);
561562
}
562563

563564
void ImGui_ImplDX10_NewFrame()

backends/imgui_impl_dx11.cpp

+12-11
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,18 @@ struct ImGui_ImplDX11_Data
6363
ImGui_ImplDX11_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
6464
};
6565

66-
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
67-
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
68-
static ImGui_ImplDX11_Data* ImGui_ImplDX11_CreateBackendData() { return IM_NEW(ImGui_ImplDX11_Data)(); }
69-
static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData() { return (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData; }
70-
static void ImGui_ImplDX11_DestroyBackendData() { IM_DELETE(ImGui_ImplDX11_GetBackendData()); }
71-
7266
struct VERTEX_CONSTANT_BUFFER
7367
{
7468
float mvp[4][4];
7569
};
7670

71+
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
72+
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
73+
static ImGui_ImplDX11_Data* ImGui_ImplDX11_GetBackendData()
74+
{
75+
return ImGui::GetCurrentContext() ? (ImGui_ImplDX11_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
76+
}
77+
7778
// Functions
7879
static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceContext* ctx)
7980
{
@@ -536,7 +537,7 @@ bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_co
536537
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
537538

538539
// Setup backend capabilities flags
539-
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_CreateBackendData();
540+
ImGui_ImplDX11_Data* bd = IM_NEW(ImGui_ImplDX11_Data)();
540541
io.BackendRendererUserData = (void*)bd;
541542
io.BackendRendererName = "imgui_impl_dx11";
542543
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
@@ -568,12 +569,12 @@ void ImGui_ImplDX11_Shutdown()
568569
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
569570

570571
ImGui_ImplDX11_InvalidateDeviceObjects();
571-
if (bd->pFactory) { bd->pFactory->Release(); bd->pFactory = NULL; }
572-
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); bd->pd3dDevice = NULL; }
573-
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); bd->pd3dDeviceContext = NULL; }
572+
if (bd->pFactory) { bd->pFactory->Release(); }
573+
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
574+
if (bd->pd3dDeviceContext) { bd->pd3dDeviceContext->Release(); }
574575
io.BackendRendererName = NULL;
575576
io.BackendRendererUserData = NULL;
576-
ImGui_ImplDX11_DestroyBackendData();
577+
IM_DELETE(bd);
577578
}
578579

579580
void ImGui_ImplDX11_NewFrame()

backends/imgui_impl_dx12.cpp

+18-16
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,19 @@ struct ImGui_ImplDX12_Data
7474
ImGui_ImplDX12_Data() { memset(this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
7575
};
7676

77-
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
78-
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
79-
static ImGui_ImplDX12_Data* ImGui_ImplDX12_CreateBackendData() { return IM_NEW(ImGui_ImplDX12_Data)(); }
80-
static ImGui_ImplDX12_Data* ImGui_ImplDX12_GetBackendData() { return (ImGui_ImplDX12_Data*)ImGui::GetIO().BackendRendererUserData; }
81-
static void ImGui_ImplDX12_DestroyBackendData() { IM_DELETE(ImGui_ImplDX12_GetBackendData()); }
82-
83-
template<typename T>
84-
static void SafeRelease(T*& res)
85-
{
86-
if (res)
87-
res->Release();
88-
res = NULL;
89-
}
90-
9177
struct VERTEX_CONSTANT_BUFFER
9278
{
9379
float mvp[4][4];
9480
};
9581

82+
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
83+
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
84+
static ImGui_ImplDX12_Data* ImGui_ImplDX12_GetBackendData()
85+
{
86+
return ImGui::GetCurrentContext() ? (ImGui_ImplDX12_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
87+
}
88+
89+
// Functions
9690
static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx, ImGui_ImplDX12_RenderBuffers* fr)
9791
{
9892
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_GetBackendData();
@@ -150,6 +144,14 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
150144
ctx->OMSetBlendFactor(blend_factor);
151145
}
152146

147+
template<typename T>
148+
static inline void SafeRelease(T*& res)
149+
{
150+
if (res)
151+
res->Release();
152+
res = NULL;
153+
}
154+
153155
// Render function
154156
void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandList* ctx)
155157
{
@@ -691,7 +693,7 @@ bool ImGui_ImplDX12_Init(ID3D12Device* device, int num_frames_in_flight, DXGI_FO
691693
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
692694

693695
// Setup backend capabilities flags
694-
ImGui_ImplDX12_Data* bd = ImGui_ImplDX12_CreateBackendData();
696+
ImGui_ImplDX12_Data* bd = IM_NEW(ImGui_ImplDX12_Data)();
695697
io.BackendRendererUserData = (void*)bd;
696698
io.BackendRendererName = "imgui_impl_dx12";
697699
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
@@ -727,7 +729,7 @@ void ImGui_ImplDX12_Shutdown()
727729
delete[] bd->pFrameResources;
728730
io.BackendRendererName = NULL;
729731
io.BackendRendererUserData = NULL;
730-
ImGui_ImplDX12_DestroyBackendData();
732+
IM_DELETE(bd);
731733
}
732734

733735
void ImGui_ImplDX12_NewFrame()

backends/imgui_impl_dx9.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ struct ImGui_ImplDX9_Data
4949
ImGui_ImplDX9_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
5050
};
5151

52-
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
53-
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
54-
static ImGui_ImplDX9_Data* ImGui_ImplDX9_CreateBackendData() { return IM_NEW(ImGui_ImplDX9_Data)(); }
55-
static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData() { return (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData; }
56-
static void ImGui_ImplDX9_DestroyBackendData() { IM_DELETE(ImGui_ImplDX9_GetBackendData()); }
57-
5852
struct CUSTOMVERTEX
5953
{
6054
float pos[3];
@@ -69,6 +63,13 @@ struct CUSTOMVERTEX
6963
#define IMGUI_COL_TO_DX9_ARGB(_COL) (((_COL) & 0xFF00FF00) | (((_COL) & 0xFF0000) >> 16) | (((_COL) & 0xFF) << 16))
7064
#endif
7165

66+
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
67+
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
68+
static ImGui_ImplDX9_Data* ImGui_ImplDX9_GetBackendData()
69+
{
70+
return ImGui::GetCurrentContext() ? (ImGui_ImplDX9_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
71+
}
72+
7273
// Functions
7374
static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data)
7475
{
@@ -274,7 +275,7 @@ bool ImGui_ImplDX9_Init(IDirect3DDevice9* device)
274275
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
275276

276277
// Setup backend capabilities flags
277-
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_CreateBackendData();
278+
ImGui_ImplDX9_Data* bd = IM_NEW(ImGui_ImplDX9_Data)();
278279
io.BackendRendererUserData = (void*)bd;
279280
io.BackendRendererName = "imgui_impl_dx9";
280281
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
@@ -291,10 +292,10 @@ void ImGui_ImplDX9_Shutdown()
291292
ImGui_ImplDX9_Data* bd = ImGui_ImplDX9_GetBackendData();
292293

293294
ImGui_ImplDX9_InvalidateDeviceObjects();
294-
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); bd->pd3dDevice = NULL; }
295+
if (bd->pd3dDevice) { bd->pd3dDevice->Release(); }
295296
io.BackendRendererName = NULL;
296297
io.BackendRendererUserData = NULL;
297-
ImGui_ImplDX9_DestroyBackendData();
298+
IM_DELETE(bd);
298299
}
299300

300301
static bool ImGui_ImplDX9_CreateFontsTexture()

backends/imgui_impl_glfw.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ struct ImGui_ImplGlfw_Data
9090
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
9191
// FIXME: multi-context support is not well tested and probably dysfunctional in this backend.
9292
// FIXME: some shared resources (mouse cursor shape, gamepad) are mishandled when using multi-context.
93-
static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_CreateBackendData() { return IM_NEW(ImGui_ImplGlfw_Data)(); }
94-
static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData() { return (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData; }
95-
static void ImGui_ImplGlfw_DestroyBackendData() { IM_DELETE(ImGui_ImplGlfw_GetBackendData()); }
93+
static ImGui_ImplGlfw_Data* ImGui_ImplGlfw_GetBackendData()
94+
{
95+
return ImGui::GetCurrentContext() ? (ImGui_ImplGlfw_Data*)ImGui::GetIO().BackendPlatformUserData : NULL;
96+
}
9697

9798
// Functions
9899
static const char* ImGui_ImplGlfw_GetClipboardText(void* user_data)
@@ -167,16 +168,16 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
167168
ImGuiIO& io = ImGui::GetIO();
168169
IM_ASSERT(io.BackendPlatformUserData == NULL && "Already initialized a platform backend!");
169170

170-
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_CreateBackendData();
171-
bd->Window = window;
172-
bd->Time = 0.0;
173-
174171
// Setup backend capabilities flags
172+
ImGui_ImplGlfw_Data* bd = IM_NEW(ImGui_ImplGlfw_Data)();
175173
io.BackendPlatformUserData = (void*)bd;
176174
io.BackendPlatformName = "imgui_impl_glfw";
177175
io.BackendFlags |= ImGuiBackendFlags_HasMouseCursors; // We can honor GetMouseCursor() values (optional)
178176
io.BackendFlags |= ImGuiBackendFlags_HasSetMousePos; // We can honor io.WantSetMousePos requests (optional, rarely used)
179177

178+
bd->Window = window;
179+
bd->Time = 0.0;
180+
180181
// Keyboard mapping. Dear ImGui will use those indices to peek into the io.KeysDown[] array.
181182
io.KeyMap[ImGuiKey_Tab] = GLFW_KEY_TAB;
182183
io.KeyMap[ImGuiKey_LeftArrow] = GLFW_KEY_LEFT;
@@ -282,7 +283,7 @@ void ImGui_ImplGlfw_Shutdown()
282283

283284
io.BackendPlatformName = NULL;
284285
io.BackendPlatformUserData = NULL;
285-
ImGui_ImplGlfw_DestroyBackendData();
286+
IM_DELETE(bd);
286287
}
287288

288289
static void ImGui_ImplGlfw_UpdateMousePosAndButtons()

backends/imgui_impl_opengl2.cpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ struct ImGui_ImplOpenGL2_Data
6565

6666
// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
6767
// It is STRONGLY preferred that you use docking branch with multi-viewports (== single Dear ImGui context + multiple windows) instead of multiple Dear ImGui contexts.
68-
static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_CreateBackendData() { return IM_NEW(ImGui_ImplOpenGL2_Data)(); }
69-
static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData() { return (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData; }
70-
static void ImGui_ImplOpenGL2_DestroyBackendData() { IM_DELETE(ImGui_ImplOpenGL2_GetBackendData()); }
68+
static ImGui_ImplOpenGL2_Data* ImGui_ImplOpenGL2_GetBackendData()
69+
{
70+
return ImGui::GetCurrentContext() ? (ImGui_ImplOpenGL2_Data*)ImGui::GetIO().BackendRendererUserData : NULL;
71+
}
7172

7273
// Functions
7374
bool ImGui_ImplOpenGL2_Init()
@@ -76,7 +77,7 @@ bool ImGui_ImplOpenGL2_Init()
7677
IM_ASSERT(io.BackendRendererUserData == NULL && "Already initialized a renderer backend!");
7778

7879
// Setup backend capabilities flags
79-
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_CreateBackendData();
80+
ImGui_ImplOpenGL2_Data* bd = IM_NEW(ImGui_ImplOpenGL2_Data)();
8081
io.BackendRendererUserData = (void*)bd;
8182
io.BackendRendererName = "imgui_impl_opengl2";
8283

@@ -86,11 +87,12 @@ bool ImGui_ImplOpenGL2_Init()
8687
void ImGui_ImplOpenGL2_Shutdown()
8788
{
8889
ImGuiIO& io = ImGui::GetIO();
90+
ImGui_ImplOpenGL2_Data* bd = ImGui_ImplOpenGL2_GetBackendData();
8991

9092
ImGui_ImplOpenGL2_DestroyDeviceObjects();
9193
io.BackendRendererName = NULL;
9294
io.BackendRendererUserData = NULL;
93-
ImGui_ImplOpenGL2_DestroyBackendData();
95+
IM_DELETE(bd);
9496
}
9597

9698
void ImGui_ImplOpenGL2_NewFrame()

0 commit comments

Comments
 (0)