diff --git a/plugins/qpa/sharingplatformcontext.cpp b/plugins/qpa/sharingplatformcontext.cpp
index 895da23b47..a6e4b2bd83 100644
--- a/plugins/qpa/sharingplatformcontext.cpp
+++ b/plugins/qpa/sharingplatformcontext.cpp
@@ -26,6 +26,7 @@ along with this program. If not, see .
#include
#include
+#include
namespace KWin
{
@@ -48,6 +49,10 @@ SharingPlatformContext::SharingPlatformContext(QOpenGLContext *context, const EG
bool SharingPlatformContext::makeCurrent(QPlatformSurface *surface)
{
Window *window = static_cast(surface);
+
+ // QOpenGLContext::makeCurrent in Qt5.12 calls platfrom->setContext before setCurrentContext
+ // but binding the content FBO looks up the format from the current context, so we need // to make sure sure Qt knows what the correct one is already
+ QOpenGLContextPrivate::setCurrentContext(context());
if (eglMakeCurrent(eglDisplay(), m_surface, m_surface, eglContext())) {
window->bindContentFBO();
return true;