// In this binding, ImTextureID is used to store a 'D3D12_GPU_DESCRIPTOR_HANDLE' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
// Implemented features:
// [X] User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui
#include<imgui.h>
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2018-02-22: Merged into master with all Win32 code synchronized to other examples.
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.
if(g_pFontTextureResource){g_pFontTextureResource->Release();g_pFontTextureResource=NULL;ImGui::GetIO().Fonts->TexID=NULL;}// We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well.
@ -644,7 +705,7 @@ bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
g_numFramesInFlight=num_frames_in_flight;
g_frameIndex=UINT_MAX;
for(inti=0;i<num_frames_in_flight;++i)
for(inti=0;i<num_frames_in_flight;i++)
{
g_pFrameResources[i].IB=NULL;
g_pFrameResources[i].VB=NULL;
@ -667,8 +728,10 @@ bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
io.KeyMap[ImGuiKey_PageDown]=VK_NEXT;
io.KeyMap[ImGuiKey_Home]=VK_HOME;
io.KeyMap[ImGuiKey_End]=VK_END;
io.KeyMap[ImGuiKey_Insert]=VK_INSERT;
io.KeyMap[ImGuiKey_Delete]=VK_DELETE;
io.KeyMap[ImGuiKey_Backspace]=VK_BACK;
io.KeyMap[ImGuiKey_Space]=VK_SPACE;
io.KeyMap[ImGuiKey_Enter]=VK_RETURN;
io.KeyMap[ImGuiKey_Escape]=VK_ESCAPE;
io.KeyMap[ImGuiKey_A]='A';
@ -678,7 +741,6 @@ bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
io.KeyMap[ImGuiKey_Y]='Y';
io.KeyMap[ImGuiKey_Z]='Z';
io.RenderDrawListsFn=ImGui_ImplDX12_RenderDrawLists;// Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
io.ImeWindowHandle=g_hWnd;
returntrue;
@ -687,7 +749,6 @@ bool ImGui_ImplDX12_Init(void* hwnd, int num_frames_in_flight,
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
// In this binding, ImTextureID is used to store a 'D3D12_GPU_DESCRIPTOR_HANDLE' texture identifier. Read the FAQ about ImTextureID in imgui.cpp.
// FIXME: 64-bit only for now! (Because sizeof(ImTextureId) == sizeof(void*))
// Implemented features:
// [X] User texture binding. Use 'D3D12_GPU_DESCRIPTOR_HANDLE' as ImTextureID. Read the FAQ about ImTextureID in imgui.cpp.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you use this binding you'll need to call 4 functions: ImGui_ImplXXXX_Init(), ImGui_ImplXXXX_NewFrame(), ImGui::Render() and ImGui_ImplXXXX_Shutdown().
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
//ImGuiIO& io = ImGui::GetIO();
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Read 'misc/fonts/README.txt' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
if(show_test_window)
// 3. Show the ImGui demo window. Most of the sample code is in ImGui::ShowDemoWindow(). Read its code to learn more about Dear ImGui!
if(show_demo_window)
{
ImGui::SetNextWindowPos(ImVec2(650,20),ImGuiCond_FirstUseEver);// Normally user code doesn't need/want to call it because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!
ImGui::ShowTestWindow(&show_test_window);
ImGui::SetNextWindowPos(ImVec2(650,20),ImGuiCond_FirstUseEver);// Normally user code doesn't need/want to call this because positions are saved in .ini file anyway. Here we just want to make the demo initial state a bit more friendly!