
Setup:
* t-engine4, version 1.7.4 or from git master
* SDL 2.0.18, or from git master
* env variable SDL_VIDEODRIVER=wayland
* Running in windowed mode with Wayland compositor Sway
Symptoms
When running t-engine4 in this setup, almost all rectangles on screen are drawn with a solid color, instead of with their image contents. After going to the Load Game/New Game dialog and back a few times, textures draw normally again. Resizing the window sometimes clears some textures again.
Cause
Calling SDL_GetWindowSurface with the Wayland backend can create a second OpenGL context, which gets made current unpredictably (when resizing ?); some OpenGl operations like texture loading happen in the wrong context, leaving the textures invalid in the correct context. The documentation for SDL_GetWindowSurface warns: "You may not combine this with 3D or the rendering API on this window.".
Fix
I've attached a patch which fixes this problem, by replacing all uses of SDL_GetWindowSurface()->w with SDL_GetWindowSize(...) . The patch is in the public domain, and is also offered under CC-0 license , so no attribution will be necessary.