mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17: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,9 +587,9 @@ static void ImGui_ImplDX10_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplDX10_RenderViewport(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx10* data = (ImGuiPlatformDataDx10*)viewport->RendererUserData;
|
||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
||||
clear_color.w = 1.0f;
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
g_pd3dDevice->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
g_pd3dDevice->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
ImGui_ImplDX10_RenderDrawData(&viewport->DrawData);
|
||||
}
|
||||
|
@ -595,9 +595,9 @@ static void ImGui_ImplDX11_ResizeViewport(ImGuiViewport* viewport, ImVec2 size)
|
||||
static void ImGui_ImplDX11_RenderViewport(ImGuiViewport* viewport)
|
||||
{
|
||||
ImGuiPlatformDataDx11* data = (ImGuiPlatformDataDx11*)viewport->RendererUserData;
|
||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
||||
clear_color.w = 1.0f;
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
ImGui_ImplDX11_RenderDrawData(&viewport->DrawData);
|
||||
}
|
||||
|
@ -734,9 +734,9 @@ static void ImGui_ImplDX12_RenderViewport(ImGuiViewport* viewport)
|
||||
IM_ASSERT(0);
|
||||
(void)data;
|
||||
/*
|
||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg]; // FIXME-PLATFORM
|
||||
clear_color.w = 1.0f;
|
||||
ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
g_pd3dDeviceContext->OMSetRenderTargets(1, &data->RTView, NULL);
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
g_pd3dDeviceContext->ClearRenderTargetView(data->RTView, (float*)&clear_color);
|
||||
*/
|
||||
ImGui_ImplDX12_RenderDrawData(&viewport->DrawData);
|
||||
|
@ -331,9 +331,12 @@ void ImGui_ImplOpenGL3_DestroyDeviceObjects()
|
||||
|
||||
static void ImGui_ImplOpenGL3_RenderViewport(ImGuiViewport* viewport)
|
||||
{
|
||||
ImVec4 clear_color = ImGui::GetStyle().Colors[ImGuiCol_WindowBg];
|
||||
glClearColor(clear_color.x, clear_color.y, clear_color.z, 1.0f); // FIXME-PLATFORM
|
||||
if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -757,6 +757,7 @@ ImGui_ImplVulkan_WindowData::ImGui_ImplVulkan_WindowData()
|
||||
memset(&SurfaceFormat, 0, sizeof(SurfaceFormat));
|
||||
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
|
||||
RenderPass = VK_NULL_HANDLE;
|
||||
ClearEnable = true;
|
||||
memset(&ClearValue, 0, sizeof(ClearValue));
|
||||
BackBufferCount = 0;
|
||||
memset(&BackBuffer, 0, sizeof(BackBuffer));
|
||||
@ -959,7 +960,7 @@ void ImGui_ImplVulkanH_CreateWindowDataSwapChainAndFramebuffer(VkPhysicalDevice
|
||||
VkAttachmentDescription attachment = {};
|
||||
attachment.format = wd->SurfaceFormat.format;
|
||||
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.stencilLoadOp = VK_ATTACHMENT_LOAD_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);
|
||||
|
||||
// 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_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;
|
||||
if (data == NULL) // This is NULL for the main viewport (which is left to the user/app to handle)
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1119,9 +1122,6 @@ static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
||||
ImGui_ImplVulkan_WindowData* wd = &data->WindowData;
|
||||
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];
|
||||
for (;;)
|
||||
@ -1145,19 +1145,21 @@ static void ImGui_ImplVulkan_RenderViewport(ImGuiViewport* viewport)
|
||||
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 = {};
|
||||
info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
||||
info.renderPass = wd->RenderPass;
|
||||
info.framebuffer = wd->Framebuffer[fd->BackbufferIndex];
|
||||
info.renderArea.extent.width = wd->Width;
|
||||
info.renderArea.extent.height = wd->Height;
|
||||
info.clearValueCount = 1;
|
||||
info.pClearValues = &wd->ClearValue;
|
||||
info.clearValueCount = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? 0 : 1;
|
||||
info.pClearValues = (viewport->Flags & ImGuiViewportFlags_NoRendererClear) ? NULL : &wd->ClearValue;
|
||||
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);
|
||||
|
||||
{
|
||||
|
@ -77,6 +77,7 @@ struct ImGui_ImplVulkan_WindowData
|
||||
VkSurfaceFormatKHR SurfaceFormat;
|
||||
VkPresentModeKHR PresentMode;
|
||||
VkRenderPass RenderPass;
|
||||
bool ClearEnable;
|
||||
VkClearValue ClearValue;
|
||||
uint32_t BackBufferCount;
|
||||
VkImage BackBuffer[16];
|
||||
|
@ -6053,6 +6053,10 @@ static void ImGui::UpdateWindowViewport(ImGuiWindow* window, bool window_pos_set
|
||||
|
||||
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);
|
||||
if (window->Viewport->PlatformRequestResize)
|
||||
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));
|
||||
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);
|
||||
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);
|
||||
|
||||
// Title bar
|
||||
|
@ -510,9 +510,10 @@ enum ImGuiViewportFlags_
|
||||
{
|
||||
ImGuiViewportFlags_MainViewport = 1 << 0,
|
||||
ImGuiViewportFlags_HostOtherWindows = 1 << 1,
|
||||
ImGuiViewportFlags_NoDecoration = 1 << 2, // Platform Window: Disable platform title bar, borders, etc.
|
||||
ImGuiViewportFlags_NoFocusOnAppearing = 1 << 3, // Platform Window: Don't take focus when created.
|
||||
ImGuiViewportFlags_NoInputs = 1 << 4 // Platform Window: Make mouse pass through so we can drag this window while peaking behind it.
|
||||
ImGuiViewportFlags_NoRendererClear = 1 << 2, // Platform Window: Renderer doesn't need to clear the framebuffer ahead.
|
||||
ImGuiViewportFlags_NoDecoration = 1 << 3, // Platform Window: Disable platform title bar, borders, etc.
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user