Skip to content

Commit 0582133

Browse files
committed
Make sure we use alpha of 0 when clearing a transparent window with no content
1 parent ecd56bb commit 0582133

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/render/metal/SDL_render_metal.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,10 @@ static int METAL_RenderPresent(SDL_Renderer *renderer)
15251525

15261526
// If we don't have a command buffer, we can't present, so activate to get one.
15271527
if (data.mtlcmdencoder == nil) {
1528-
// We haven't even gotten a backbuffer yet? Clear it to black. Otherwise, load the existing data.
1528+
// We haven't even gotten a backbuffer yet? Load and clear it. Otherwise, load the existing data.
15291529
if (data.mtlbackbuffer == nil) {
1530-
MTLClearColor color = MTLClearColorMake(0.0f, 0.0f, 0.0f, 1.0f);
1530+
float alpha = (SDL_GetWindowFlags(renderer->window) & SDL_WINDOW_TRANSPARENT) ? 0.0f : 1.0f;
1531+
MTLClearColor color = MTLClearColorMake(0.0f, 0.0f, 0.0f, alpha);
15311532
ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionClear, &color, nil);
15321533
} else {
15331534
ready = METAL_ActivateRenderCommandEncoder(renderer, MTLLoadActionLoad, NULL, nil);

0 commit comments

Comments
 (0)