- Added SDL_WINDOW_TRANSPARENT to request a window with transparent framebuffer

- Remove SDL_VIDEO_EGL_ALLOW_TRANSPARENCY hint, EGL now checks 'window->flags & SDL_WINDOW_TRANSPARENT'
This commit is contained in:
Sylvain
2023-03-11 13:53:14 +01:00
committed by Sylvain Becker
parent 4dededd345
commit 2cafa52598
30 changed files with 136 additions and 103 deletions

View File

@@ -92,7 +92,7 @@ static void Render(void)
};
/* Do our drawing, too. */
ctx.glClearColor(0.0, 0.0, 0.0, 1.0);
ctx.glClearColor(0.0, 0.0, 0.0, 0.0 /* used with --transparent */);
ctx.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
ctx.glBegin(GL_QUADS);

View File

@@ -126,7 +126,7 @@ static void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite)
}
/* Draw a gray background */
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0x00 /* used with --transparent */);
SDL_RenderClear(renderer);
/* Test points */

View File

@@ -624,6 +624,7 @@ static SDL_bool createSwapchain(void)
int w, h;
VkSwapchainCreateInfoKHR createInfo = { 0 };
VkResult result;
Uint32 flags;
// pick an image count
vulkanContext->swapchainDesiredImageCount = vulkanContext->surfaceCapabilities.minImageCount + 1;
@@ -651,6 +652,9 @@ static SDL_bool createSwapchain(void)
// get size
SDL_GetWindowSizeInPixels(vulkanContext->window, &w, &h);
// get flags
flags = SDL_GetWindowFlags(vulkanContext->window);
// Clamp the size to the allowable image extent.
// SDL_GetWindowSizeInPixels()'s result it not always in this range (bug #3287)
vulkanContext->swapchainSize.width = SDL_clamp((uint32_t)w,
@@ -677,7 +681,11 @@ static SDL_bool createSwapchain(void)
createInfo.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.preTransform = vulkanContext->surfaceCapabilities.currentTransform;
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
if (flags & SDL_WINDOW_TRANSPARENT) {
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR;
} else {
createInfo.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
}
createInfo.presentMode = VK_PRESENT_MODE_FIFO_KHR;
createInfo.clipped = VK_TRUE;
createInfo.oldSwapchain = vulkanContext->swapchain;
@@ -1037,7 +1045,7 @@ static SDL_bool render(void)
clearColor.float32[0] = (float)(0.5 + 0.5 * SDL_sin(currentTime));
clearColor.float32[1] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 2 / 3));
clearColor.float32[2] = (float)(0.5 + 0.5 * SDL_sin(currentTime + SDL_PI_D * 4 / 3));
clearColor.float32[3] = 1;
clearColor.float32[3] = 0.5; // for SDL_WINDOW_TRANSPARENT, ignored with VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR
rerecordCommandBuffer(frameIndex, &clearColor);
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.waitSemaphoreCount = 1;