libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.98k stars 1.84k forks source link

[SDL3] No background on window #9529

Closed TwistedBlizzard closed 5 months ago

TwistedBlizzard commented 7 months ago

OS: Arch Linux GPU: Nvidia RTX 3060 (Mobile) Desktop Environment: KDE (Wayland)

Hey folks,

When I create a window, I get the following errors and the window appears fully transparent:

libEGL warning: egl: failed to create dri2 screen
MESA: error: ZINK: vkCreateInstance failed (VK_ERROR_INCOMPATIBLE_DRIVER)
libEGL warning: egl: failed to create dri2 screen

Here's how I'm creating the window:

SDL_Init(SDL_INIT_EVENTS | SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)

SDL_Window* window = nullptr;
SDL_Renderer* renderer = nullptr;

SDL_CreateWindowAndRenderer(1024, 768, SDL_WINDOW_RESIZABLE, &window, &renderer);

But the line SDL_Renderer* renderer = SDL_CreateRenderer(window, NULL, 0); throws the same errors.

Manually calling SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); fixes the transparency but the errors are still present.

I'm building from source using CMake with fetchcontent pulling the latest commit on this repo.

The same code runs fine on Windows.

Kontrabant commented 7 months ago

The errors are from MESA, probably related to this: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10293

Manually calling SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE); fixes the transparency but the errors are still present.

By default, the clear color alpha channel is zero, so if KDE honors the render target alpha channel, this makes sense. SDL does set the window opaque region when SDL_WINDOW_TRANSPARENT isn't set on a window, but it's just a hint that the compositor is free to ignore.

Kontrabant commented 7 months ago

Hmm, actually, SDL also sets the EGL_PRESENT_OPAQUE_EXT and VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR properties on backbuffers for non-transparent windows, so the alpha channel should be ignored. This might be a KDE or MESA bug.

sechshelme commented 7 months ago

I have a similar problem. The window is black at the beginning, but when I enlarge it, it looks like the attachment. Using Linux Mint 64bit with x11 and cinnamon. GPU Intel i915 There is no message in the console. Bildschirmfoto vom 2024-04-17 19-47-55

Kontrabant commented 7 months ago

Are you actually drawing anything to the window? Windows on several platforms don't react well if they are resized without being repainted.