Skip to content

Commit 51862b0

Browse files
committed
v2: Update example plugin imgui backends to match current imgui version
Copied imgui_impl_dx11/dx12/win32 from dependencies/imgui/backends/. Added ImGui_ImplWin32_WndProcHandler forward declaration in Plugin.cpp (required by newer imgui which wraps the declaration in #if 0).
1 parent 079396a commit 51862b0

7 files changed

Lines changed: 1571 additions & 817 deletions

File tree

examples/example_plugin/Plugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
#include "imgui/imgui_impl_dx12.h"
1313
#include "imgui/imgui_impl_win32.h"
1414

15+
// Forward declaration required by newer imgui backends
16+
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
17+
1518
#include "rendering/d3d11.hpp"
1619
#include "rendering/d3d12.hpp"
1720

examples/example_plugin/imgui/imgui_impl_dx11.cpp

Lines changed: 341 additions & 215 deletions
Large diffs are not rendered by default.

examples/example_plugin/imgui/imgui_impl_dx11.h

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,50 @@
22
// This needs to be used along with a Platform Backend (e.g. Win32)
33

44
// Implemented features:
5-
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as ImTextureID. Read the FAQ about ImTextureID!
6-
// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices.
5+
// [X] Renderer: User texture binding. Use 'ID3D11ShaderResourceView*' as texture identifier. Read the FAQ about ImTextureID/ImTextureRef!
6+
// [X] Renderer: Large meshes support (64k+ vertices) even with 16-bit indices (ImGuiBackendFlags_RendererHasVtxOffset).
7+
// [X] Renderer: Texture updates support for dynamic font atlas (ImGuiBackendFlags_RendererHasTextures).
8+
// [X] Renderer: Expose selected render state for draw callbacks to use. Access in '(ImGui_ImplXXXX_RenderState*)GetPlatformIO().Renderer_RenderState'.
79

8-
// You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
9-
// If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp.
10-
// Read online: https://github.com/ocornut/imgui/tree/master/docs
10+
// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
11+
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
12+
// Learn about Dear ImGui:
13+
// - FAQ https://dearimgui.com/faq
14+
// - Getting Started https://dearimgui.com/getting-started
15+
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
16+
// - Introduction, links and more at the top of imgui.cpp
1117

1218
#pragma once
1319
#include "imgui.h" // IMGUI_IMPL_API
20+
#ifndef IMGUI_DISABLE
1421

1522
struct ID3D11Device;
1623
struct ID3D11DeviceContext;
24+
struct ID3D11SamplerState;
25+
struct ID3D11Buffer;
1726

27+
// Follow "Getting Started" link and check examples/ folder to learn about using backends!
1828
IMGUI_IMPL_API bool ImGui_ImplDX11_Init(ID3D11Device* device, ID3D11DeviceContext* device_context);
1929
IMGUI_IMPL_API void ImGui_ImplDX11_Shutdown();
2030
IMGUI_IMPL_API void ImGui_ImplDX11_NewFrame();
2131
IMGUI_IMPL_API void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data);
2232

2333
// Use if you want to reset your rendering device without losing Dear ImGui state.
34+
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
2435
IMGUI_IMPL_API void ImGui_ImplDX11_InvalidateDeviceObjects();
25-
IMGUI_IMPL_API bool ImGui_ImplDX11_CreateDeviceObjects();
36+
37+
// (Advanced) Use e.g. if you need to precisely control the timing of texture updates (e.g. for staged rendering), by setting ImDrawData::Textures = NULL to handle this manually.
38+
IMGUI_IMPL_API void ImGui_ImplDX11_UpdateTexture(ImTextureData* tex);
39+
40+
// [BETA] Selected render state data shared with callbacks.
41+
// This is temporarily stored in GetPlatformIO().Renderer_RenderState during the ImGui_ImplDX11_RenderDrawData() call.
42+
// (Please open an issue if you feel you need access to more data)
43+
struct ImGui_ImplDX11_RenderState
44+
{
45+
ID3D11Device* Device;
46+
ID3D11DeviceContext* DeviceContext;
47+
ID3D11SamplerState* SamplerDefault;
48+
ID3D11Buffer* VertexConstantBuffer;
49+
};
50+
51+
#endif // #ifndef IMGUI_DISABLE

0 commit comments

Comments
 (0)