|
@@ -17,56 +17,60 @@ You can find Windows binaries for some of those example applications at:
|
|
|
|
|
|
Integration in a typical existing application, should take <20 lines when using standard backends.
|
|
|
|
|
|
- At initialization:
|
|
|
- call ImGui::CreateContext()
|
|
|
- call ImGui_ImplXXXX_Init() for each backend.
|
|
|
+```cpp
|
|
|
+At initialization:
|
|
|
+ call ImGui::CreateContext()
|
|
|
+ call ImGui_ImplXXXX_Init() for each backend.
|
|
|
|
|
|
- At the beginning of your frame:
|
|
|
- call ImGui_ImplXXXX_NewFrame() for each backend.
|
|
|
- call ImGui::NewFrame()
|
|
|
+At the beginning of your frame:
|
|
|
+ call ImGui_ImplXXXX_NewFrame() for each backend.
|
|
|
+ call ImGui::NewFrame()
|
|
|
|
|
|
- At the end of your frame:
|
|
|
- call ImGui::Render()
|
|
|
- call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend.
|
|
|
+At the end of your frame:
|
|
|
+ call ImGui::Render()
|
|
|
+ call ImGui_ImplXXXX_RenderDrawData() for your Renderer backend.
|
|
|
|
|
|
- At shutdown:
|
|
|
- call ImGui_ImplXXXX_Shutdown() for each backend.
|
|
|
- call ImGui::DestroyContext()
|
|
|
+At shutdown:
|
|
|
+ call ImGui_ImplXXXX_Shutdown() for each backend.
|
|
|
+ call ImGui::DestroyContext()
|
|
|
+```
|
|
|
|
|
|
Example (using [backends/imgui_impl_win32.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_win32.cpp) + [backends/imgui_impl_dx11.cpp](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp)):
|
|
|
|
|
|
- // Create a Dear ImGui context, setup some options
|
|
|
- ImGui::CreateContext();
|
|
|
- ImGuiIO& io = ImGui::GetIO();
|
|
|
- io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options
|
|
|
-
|
|
|
- // Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp)
|
|
|
- ImGui_ImplWin32_Init(my_hwnd);
|
|
|
- ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context);
|
|
|
-
|
|
|
- // Application main loop
|
|
|
- while (true)
|
|
|
- {
|
|
|
- // Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame
|
|
|
- ImGui_ImplDX11_NewFrame();
|
|
|
- ImGui_ImplWin32_NewFrame();
|
|
|
- ImGui::NewFrame();
|
|
|
-
|
|
|
- // Any application code here
|
|
|
- ImGui::Text("Hello, world!");
|
|
|
-
|
|
|
- // End of frame: render Dear ImGui
|
|
|
- ImGui::Render();
|
|
|
- ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
|
|
-
|
|
|
- // Swap
|
|
|
- g_pSwapChain->Present(1, 0);
|
|
|
- }
|
|
|
-
|
|
|
- // Shutdown
|
|
|
- ImGui_ImplDX11_Shutdown();
|
|
|
- ImGui_ImplWin32_Shutdown();
|
|
|
- ImGui::DestroyContext();
|
|
|
+```cpp
|
|
|
+// Create a Dear ImGui context, setup some options
|
|
|
+ImGui::CreateContext();
|
|
|
+ImGuiIO& io = ImGui::GetIO();
|
|
|
+io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable some options
|
|
|
+
|
|
|
+// Initialize Platform + Renderer backends (here: using imgui_impl_win32.cpp + imgui_impl_dx11.cpp)
|
|
|
+ImGui_ImplWin32_Init(my_hwnd);
|
|
|
+ImGui_ImplDX11_Init(my_d3d_device, my_d3d_device_context);
|
|
|
+
|
|
|
+// Application main loop
|
|
|
+while (true)
|
|
|
+{
|
|
|
+ // Beginning of frame: update Renderer + Platform backend, start Dear ImGui frame
|
|
|
+ ImGui_ImplDX11_NewFrame();
|
|
|
+ ImGui_ImplWin32_NewFrame();
|
|
|
+ ImGui::NewFrame();
|
|
|
+
|
|
|
+ // Any application code here
|
|
|
+ ImGui::Text("Hello, world!");
|
|
|
+
|
|
|
+ // End of frame: render Dear ImGui
|
|
|
+ ImGui::Render();
|
|
|
+ ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
|
|
+
|
|
|
+ // Swap
|
|
|
+ g_pSwapChain->Present(1, 0);
|
|
|
+}
|
|
|
+
|
|
|
+// Shutdown
|
|
|
+ImGui_ImplDX11_Shutdown();
|
|
|
+ImGui_ImplWin32_Shutdown();
|
|
|
+ImGui::DestroyContext();
|
|
|
+```
|
|
|
|
|
|
Please read 'PROGRAMMER GUIDE' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.
|
|
|
Please read the comments and instruction at the top of each file.
|