Examples: Amend Win32/Winapi + OpenGL example. (#3218, #5170 and #6086, #2772, #2600, #2359, #2022, #1553)

This commit is contained in:
ocornut
2023-04-19 15:57:38 +02:00
parent a566ecc58f
commit 9308cfdcfb
4 changed files with 68 additions and 77 deletions

View File

@ -35,6 +35,7 @@ typedef DWORD (WINAPI *PFN_XInputGetState)(DWORD, XINPUT_STATE*);
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
// 2023-04-19: Added ImGui_ImplWin32_InitForOpenGL() to facilitate combining raw Win32/Winapi with OpenGL. (#3218)
// 2023-04-04: Inputs: Added support for io.AddMouseSourceEvent() to discriminate ImGuiMouseSource_Mouse/ImGuiMouseSource_TouchScreen/ImGuiMouseSource_Pen. (#2702)
// 2023-02-15: Inputs: Use WM_NCMOUSEMOVE / WM_NCMOUSELEAVE to track mouse position over non-client area (e.g. OS decorations) when app is not focused. (#6045, #6162)
// 2023-02-02: Inputs: Flipping WM_MOUSEHWHEEL (horizontal mouse-wheel) value to match other backends and offer consistent horizontal scrolling direction. (#4019, #6096, #1463)
@ -114,7 +115,7 @@ static ImGui_ImplWin32_Data* ImGui_ImplWin32_GetBackendData()
}
// Functions
static bool ImGui_ImplWin32_Init(void* hwnd, bool platformHasOwnDC)
static bool ImGui_ImplWin32_InitEx(void* hwnd, bool platform_has_own_dc)
{
ImGuiIO& io = ImGui::GetIO();
IM_ASSERT(io.BackendPlatformUserData == nullptr && "Already initialized a platform backend!");
@ -139,7 +140,7 @@ static bool ImGui_ImplWin32_Init(void* hwnd, bool platformHasOwnDC)
// Set platform dependent data in viewport
ImGui::GetMainViewport()->PlatformHandleRaw = (void*)hwnd;
IM_UNUSED(platformHasOwnDC); // Used in 'docking' branch
IM_UNUSED(platform_has_own_dc); // Used in 'docking' branch
// Dynamically load XInput library
#ifndef IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
@ -167,13 +168,13 @@ static bool ImGui_ImplWin32_Init(void* hwnd, bool platformHasOwnDC)
IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd)
{
return ImGui_ImplWin32_Init(hwnd, false);
return ImGui_ImplWin32_InitEx(hwnd, false);
}
IMGUI_IMPL_API bool ImGui_ImplWin32_InitForOpenGL(void* hwnd)
{
// OpenGL needs CS_OWNDC
return ImGui_ImplWin32_Init(hwnd, true);
return ImGui_ImplWin32_InitEx(hwnd, true);
}
void ImGui_ImplWin32_Shutdown()