mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Big example binding refactor (manually imported from Viewport branch, stripped out of Viewport code). (#1870)
Read examples/README.txt for some details. ImDrawData: Added DisplayPos, DisplaySize fields honored by all backends (not strictly necessary to honor just now, but doing it to be ahead)
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// If you are new to ImGui, see examples/README.txt and documentation at the top of imgui.cpp.
|
||||
|
||||
#include "imgui.h"
|
||||
#include "imgui_impl_win32.h"
|
||||
#include "imgui_impl_dx10.h"
|
||||
#include <d3d10_1.h>
|
||||
#include <d3d10.h>
|
||||
@ -116,7 +117,9 @@ int main(int, char**)
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
ImGui_ImplDX10_Init(hwnd, g_pd3dDevice);
|
||||
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX10_Init(g_pd3dDevice);
|
||||
|
||||
// Setup style
|
||||
ImGui::StyleColorsDark();
|
||||
@ -146,6 +149,7 @@ int main(int, char**)
|
||||
ZeroMemory(&msg, sizeof(msg));
|
||||
while (msg.message != WM_QUIT)
|
||||
{
|
||||
// Poll and handle messages (inputs, window resize, etc.)
|
||||
// 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.
|
||||
@ -156,7 +160,11 @@ int main(int, char**)
|
||||
DispatchMessage(&msg);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Start the ImGui frame
|
||||
ImGui_ImplDX10_NewFrame();
|
||||
ImGui_ImplWin32_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
// 1. Show a simple window.
|
||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets automatically appears in a window called "Debug".
|
||||
@ -196,9 +204,9 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
g_pd3dDevice->OMSetRenderTargets(1, &g_mainRenderTargetView, NULL);
|
||||
g_pd3dDevice->ClearRenderTargetView(g_mainRenderTargetView, (float*)&clear_color);
|
||||
ImGui::Render();
|
||||
ImGui_ImplDX10_RenderDrawData(ImGui::GetDrawData());
|
||||
|
||||
g_pSwapChain->Present(1, 0); // Present with vsync
|
||||
@ -206,6 +214,7 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
ImGui_ImplDX10_Shutdown();
|
||||
ImGui_ImplWin32_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
|
||||
CleanupDeviceD3D();
|
||||
|
Reference in New Issue
Block a user