mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Viewport: Removed back-end renderer code that implied we need to clear with WindowBg color. Added NoRendererClear flag. (#1542, #1042)
This commit is contained in:
parent
09d8943967
commit
8364d1ca6c
@ -587,10 +587,10 @@ static void ImGui_ImplDX10_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
|||||||
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
clear_color.w = 1.0f;
|
|
||||||
g_pd3dDevice->OMSetRenderTargets(1, &data->RTView, NULL);
|
g_pd3dDevice->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||||
g_pd3dDevice->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
g_pd3dDevice->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||||
ImGui_ImplDX10_RenderDrawData(&viewport->DrawData);
|
ImGui_ImplDX10_RenderDrawData(&viewport->DrawData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,10 +595,10 @@ static void ImGui_ImplDX11_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
|||||||
static void ImGui_ImplDX11_RenderViewport(ImGuiViewport* viewport)
|
static void ImGui_ImplDX11_RenderViewport(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
clear_color.w = 1.0f;
|
|
||||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||||
ImGui_ImplDX11_RenderDrawData(&viewport->DrawData);
|
ImGui_ImplDX11_RenderDrawData(&viewport->DrawData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,10 +734,10 @@ static void ImGui_ImplDX12_RenderViewport(ImGuiViewport* viewport)
|
|||||||
IM_ASSERT(0);
|
IM_ASSERT(0);
|
||||||
(void)data;
|
(void)data;
|
||||||
/*
|
/*
|
||||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
clear_color.w = 1.0f;
|
|
||||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
|
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||||
*/
|
*/
|
||||||
ImGui_ImplDX12_RenderDrawData(&viewport->DrawData);
|
ImGui_ImplDX12_RenderDrawData(&viewport->DrawData);
|
||||||
}
|
}
|
||||||
|
@ -331,9 +331,12 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
|||||||
|
|
||||||
static void ImGui_ImplOpenGL3_RenderViewport(ImGuiViewport* viewport)
|
static void ImGui_ImplOpenGL3_RenderViewport(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
|
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, 1.0f); // FIXME-PLATFORM
|
{
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClearColor(clear_color.x, clear_color.y, clear_color.z, clear_color.w);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(&viewport->DrawData);
|
ImGui_ImplOpenGL3_RenderDrawData(&viewport->DrawData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,6 +757,7 @@ ImGui_ImplVulkan_WindowData::ImGui_ImplVulkan_WindowData()
|
|||||||
memset(&SurfaceFormat, 0, sizeof(SurfaceFormat));
|
memset(&SurfaceFormat, 0, sizeof(SurfaceFormat));
|
||||||
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
|
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
|
||||||
RenderPass = VK_NULL_HANDLE;
|
RenderPass = VK_NULL_HANDLE;
|
||||||
|
ClearEnable = true;
|
||||||
memset(&ClearValue, 0, sizeof(ClearValue));
|
memset(&ClearValue, 0, sizeof(ClearValue));
|
||||||
BackBufferCount = 0;
|
BackBufferCount = 0;
|
||||||
memset(&BackBuffer, 0, sizeof(BackBuffer));
|
memset(&BackBuffer, 0, sizeof(BackBuffer));
|
||||||
@ -959,7 +960,7 @@ void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice
|
|||||||
VkAttachmentDescription attachment = {};
|
VkAttachmentDescription attachment = {};
|
||||||
attachment.format = wd->SurfaceFormat.format;
|
attachment.format = wd->SurfaceFormat.format;
|
||||||
attachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
attachment.samples = VK_SAMPLE_COUNT_1_BIT;
|
||||||
attachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
attachment.loadOp = wd->ClearEnable ? VK_ATTACHMENT_LOAD_OP_CLEAR : VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||||
attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||||
attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||||
@ -1091,6 +1092,7 @@ static void ImGui_ImplVulkan_CreateViewport(ImGuiViewport* viewport)
|
|||||||
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_mode, 1);
|
wd->PresentMode = ImGui_ImplVulkanH_SelectPresentMode(g_PhysicalDevice, wd->Surface, &present_mode, 1);
|
||||||
|
|
||||||
// Create SwapChain, RenderPass, Framebuffer, etc.
|
// Create SwapChain, RenderPass, Framebuffer, etc.
|
||||||
|
wd->ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
ImGui_ImplVulkanH_CreateWindowDataCommandBuffers(g_PhysicalDevice, g_Device, g_QueueFamily, wd, g_Allocator);
|
ImGui_ImplVulkanH_CreateWindowDataCommandBuffers(g_PhysicalDevice, g_Device, g_QueueFamily, wd, g_Allocator);
|
||||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, wd, g_Allocator, (int)viewport->Size.x, (int)viewport->Size.y);
|
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, wd, g_Allocator, (int)viewport->Size.x, (int)viewport->Size.y);
|
||||||
}
|
}
|
||||||
@ -1110,6 +1112,7 @@ static void ImGui_ImplVulkan_ResizeViewport(ImGuiViewport* viewport, ImVec2 size
|
|||||||
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
ImGuiPlatformDataVulkan* data = (ImGuiPlatformDataVulkan*)viewport->RendererUserData;
|
||||||
if (data == NULL) // This is NULL for the main viewport (which is left to the user/app to handle)
|
if (data == NULL) // This is NULL for the main viewport (which is left to the user/app to handle)
|
||||||
return;
|
return;
|
||||||
|
data->WindowData.ClearEnable = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? false : true;
|
||||||
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &data->WindowData, g_Allocator, (int)size.x, (int)size.y);
|
ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(g_PhysicalDevice, g_Device, &data->WindowData, g_Allocator, (int)size.x, (int)size.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1119,9 +1122,6 @@ static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
|||||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||||
VkResult err;
|
VkResult err;
|
||||||
|
|
||||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
|
||||||
clear_color.w = 1.0f;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
ImGui_ImplVulkan_FrameData* fd = &wd->Frames[wd->FrameIndex];
|
||||||
for (;;)
|
for (;;)
|
||||||
@ -1145,19 +1145,21 @@ static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
|||||||
check_vk_result(err);
|
check_vk_result(err);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
||||||
|
|
||||||
VkRenderPassBeginInfo info = {};
|
VkRenderPassBeginInfo info = {};
|
||||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||||
info.renderPass = wd->RenderPass;
|
info.renderPass = wd->RenderPass;
|
||||||
info.framebuffer = wd->Framebuffer[fd->BackbufferIndex];
|
info.framebuffer = wd->Framebuffer[fd->BackbufferIndex];
|
||||||
info.renderArea.extent.width = wd->Width;
|
info.renderArea.extent.width = wd->Width;
|
||||||
info.renderArea.extent.height = wd->Height;
|
info.renderArea.extent.height = wd->Height;
|
||||||
info.clearValueCount = 1;
|
info.clearValueCount = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? 0 : 1;
|
||||||
info.pClearValues = &wd->ClearValue;
|
info.pClearValues = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? NULL : &wd->ClearValue;
|
||||||
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(fd->CommandBuffer, &info, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&wd->ClearValue.color.float32[0], &clear_color, 4 * sizeof(float));
|
|
||||||
ImGui_ImplVulkan_RenderDrawData(wd->Frames[wd->FrameIndex].CommandBuffer, &viewport->DrawData);
|
ImGui_ImplVulkan_RenderDrawData(wd->Frames[wd->FrameIndex].CommandBuffer, &viewport->DrawData);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -77,6 +77,7 @@ struct ImGui_ImplVulkan_WindowData
|
|||||||
VkSurfaceFormatKHR SurfaceFormat;
|
VkSurfaceFormatKHR SurfaceFormat;
|
||||||
VkPresentModeKHR PresentMode;
|
VkPresentModeKHR PresentMode;
|
||||||
VkRenderPass RenderPass;
|
VkRenderPass RenderPass;
|
||||||
|
bool ClearEnable;
|
||||||
VkClearValue ClearValue;
|
VkClearValue ClearValue;
|
||||||
uint32_t BackBufferCount;
|
uint32_t BackBufferCount;
|
||||||
VkImage BackBuffer[16];
|
VkImage BackBuffer[16];
|
||||||
|
@ -6053,6 +6053,10 @@ static void ImGui::UpdateWindowViewport(ImGuiWindow* window, bool window_pos_set
|
|||||||
|
|
||||||
if (window->Flags & ImGuiWindowFlags_FullViewport)
|
if (window->Flags & ImGuiWindowFlags_FullViewport)
|
||||||
{
|
{
|
||||||
|
// We currently have window fully covering a viewport and we disable WindowBg alpha, so clearing is not necessary
|
||||||
|
window->Viewport->Flags |= ImGuiViewportFlags_NoRendererClear;
|
||||||
|
|
||||||
|
// Position
|
||||||
SetWindowPos(window, window->Viewport->Pos, ImGuiCond_Always);
|
SetWindowPos(window, window->Viewport->Pos, ImGuiCond_Always);
|
||||||
if (window->Viewport->PlatformRequestResize)
|
if (window->Viewport->PlatformRequestResize)
|
||||||
SetWindowSize(window, window->Viewport->Size, ImGuiCond_Always);
|
SetWindowSize(window, window->Viewport->Size, ImGuiCond_Always);
|
||||||
@ -6606,6 +6610,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
||||||
if (g.NextWindowData.BgAlphaCond != 0)
|
if (g.NextWindowData.BgAlphaCond != 0)
|
||||||
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(g.NextWindowData.BgAlphaVal) << IM_COL32_A_SHIFT);
|
bg_col = (bg_col & ~IM_COL32_A_MASK) | (IM_F32_TO_INT8_SAT(g.NextWindowData.BgAlphaVal) << IM_COL32_A_SHIFT);
|
||||||
|
if (window->Flags & ImGuiWindowFlags_FullViewport)
|
||||||
|
bg_col = (bg_col | IM_COL32_A_MASK);
|
||||||
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
window->DrawList->AddRectFilled(window->Pos+ImVec2(0,window->TitleBarHeight()), window->Pos+window->Size, bg_col, window_rounding, (flags & ImGuiWindowFlags_NoTitleBar) ? ImDrawCornerFlags_All : ImDrawCornerFlags_Bot);
|
||||||
|
|
||||||
// Title bar
|
// Title bar
|
||||||
|
@ -510,9 +510,10 @@ enum ImGuiViewportFlags_
|
|||||||
{
|
{
|
||||||
ImGuiViewportFlags_MainViewport = 1 << 0,
|
ImGuiViewportFlags_MainViewport = 1 << 0,
|
||||||
ImGuiViewportFlags_HostOtherWindows = 1 << 1,
|
ImGuiViewportFlags_HostOtherWindows = 1 << 1,
|
||||||
ImGuiViewportFlags_NoDecoration = 1 << 2, // Platform Window: Disable platform title bar, borders, etc.
|
ImGuiViewportFlags_NoRendererClear = 1 << 2, // Platform Window: Renderer doesn't need to clear the framebuffer ahead.
|
||||||
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 3, // Platform Window: Don't take focus when created.
|
ImGuiViewportFlags_NoDecoration = 1 << 3, // Platform Window: Disable platform title bar, borders, etc.
|
||||||
ImGuiViewportFlags_NoInputs = 1 << 4 // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
|
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 4, // Platform Window: Don't take focus when created.
|
||||||
|
ImGuiViewportFlags_NoInputs = 1 << 5 // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImGuiViewport
|
struct ImGuiViewport
|
||||||
|
Loading…
Reference in New Issue
Block a user