diff --git a/src/core/api/qtwebenginecoreglobal.cpp b/src/core/api/qtwebenginecoreglobal.cpp
index f5d1e6d39bbffdecc47d2725a9897b3a97217b9b..072f2796765c25c4516ecdaf2f0602f28559ebe1 100644
--- a/src/core/api/qtwebenginecoreglobal.cpp
+++ b/src/core/api/qtwebenginecoreglobal.cpp
@@ -40,16 +40,20 @@
 #include "qtwebenginecoreglobal_p.h"
 
 #include <QGuiApplication>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
 #include <QThread>
 
+#ifndef QT_NO_OPENGL
 QT_BEGIN_NAMESPACE
 Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
 Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
 QT_END_NAMESPACE
+#endif
 
 namespace QtWebEngineCore {
-
+#ifndef QT_NO_OPENGL
 static QOpenGLContext *shareContext;
 
 static void deleteShareContext()
@@ -58,6 +62,7 @@ static void deleteShareContext()
     shareContext = 0;
 }
 
+#endif
 // ### Qt 6: unify this logic and Qt::AA_ShareOpenGLContexts.
 // QtWebEngine::initialize was introduced first and meant to be called
 // after the QGuiApplication creation, when AA_ShareOpenGLContexts fills
@@ -65,6 +70,7 @@ static void deleteShareContext()
 
 QWEBENGINE_PRIVATE_EXPORT void initialize()
 {
+#ifndef QT_NO_OPENGL
 #ifdef Q_OS_WIN32
     qputenv("QT_D3DCREATE_MULTITHREADED", "1");
 #endif
@@ -100,5 +106,6 @@ QWEBENGINE_PRIVATE_EXPORT void initialize()
 
     // Classes like QOpenGLWidget check for the attribute
     app->setAttribute(Qt::AA_ShareOpenGLContexts);
+#endif // QT_NO_OPENGL
 }
 } // namespace QtWebEngineCore
diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp
index a2453070ed2645b3e2dd94e9c907e2873d99ff4f..64964dc09124e89c56c2ca63a735f5fc6b17945c 100644
--- a/src/core/content_browser_client_qt.cpp
+++ b/src/core/content_browser_client_qt.cpp
@@ -100,7 +100,9 @@
 
 #include <QGuiApplication>
 #include <QLocale>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
 #include <qpa/qplatformnativeinterface.h>
 
 QT_BEGIN_NAMESPACE
@@ -322,12 +324,14 @@ private:
 
 void ShareGroupQtQuick::AboutToAddFirstContext()
 {
+#ifndef QT_NO_OPENGL
     // This currently has to be setup by ::main in all applications using QQuickWebEngineView with delegated rendering.
     QOpenGLContext *shareContext = qt_gl_global_share_context();
     if (!shareContext) {
         qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function.");
     }
     m_shareContextQtQuick = make_scoped_refptr(new QtShareGLContext(shareContext));
+#endif
 }
 
 class QuotaPermissionContextQt : public content::QuotaPermissionContext {
diff --git a/src/core/core_gyp_generator.pro b/src/core/core_gyp_generator.pro
index f5b9f870cda29ab97b33d44ea9f5dc55639a1378..2fae21c4d33b85fdc6ea92184242323d60c03d92 100644
--- a/src/core/core_gyp_generator.pro
+++ b/src/core/core_gyp_generator.pro
@@ -96,7 +96,6 @@ SOURCES = \
         resource_bundle_qt.cpp \
         resource_context_qt.cpp \
         ssl_host_state_delegate_qt.cpp \
-        stream_video_node.cpp \
         surface_factory_qt.cpp \
         type_conversion.cpp \
         url_request_context_getter_qt.cpp \
@@ -112,8 +111,7 @@ SOURCES = \
         web_engine_library_info.cpp \
         web_engine_settings.cpp \
         web_engine_visited_links_manager.cpp \
-        web_event_factory.cpp \
-        yuv_video_node.cpp
+        web_event_factory.cpp
 
 HEADERS = \
         access_token_store_qt.h \
@@ -178,7 +176,6 @@ HEADERS = \
         renderer_host/web_channel_ipc_transport_host.h \
         resource_context_qt.h \
         ssl_host_state_delegate_qt.h \
-        stream_video_node.h \
         surface_factory_qt.h \
         type_conversion.h \
         url_request_context_getter_qt.h \
@@ -196,8 +193,17 @@ HEADERS = \
         web_engine_library_info.h \
         web_engine_settings.h \
         web_engine_visited_links_manager.h \
-        web_event_factory.h \
-        yuv_video_node.h
+        web_event_factory.h
+
+contains(QT_CONFIG, opengl) {
+    SOURCES += \
+        yuv_video_node.cpp \
+        stream_video_node.cpp
+
+    HEADERS += \
+        yuv_video_node.h \
+        stream_video_node.h
+}
 
 qtHaveModule(positioning) {
     SOURCES += location_provider_qt.cpp
diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp
index 3d147226d0fb78932ca29fa89fffedd3289b6893..44e37aeb68868078ae24cca9ed55f94da4a831f1 100644
--- a/src/core/delegated_frame_node.cpp
+++ b/src/core/delegated_frame_node.cpp
@@ -70,9 +70,11 @@
 #include "ui/gl/gl_context.h"
 #include "ui/gl/gl_fence.h"
 
-#include <QOpenGLContext>
-#include <QOpenGLFunctions>
-#include <QSGFlatColorMaterial>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+# include <QOpenGLFunctions>
+# include <QSGFlatColorMaterial>
+#endif
 #include <QSGTexture>
 #include <private/qsgadaptationlayer_p.h>
 
@@ -97,8 +99,20 @@
 #define GL_TEXTURE_RECTANGLE              0x84F5
 #endif
 
-namespace QtWebEngineCore {
+#ifndef GL_LINEAR
+#define GL_LINEAR                         0x2601
+#endif
 
+#ifndef GL_RGBA
+#define GL_RGBA                           0x1908
+#endif
+
+#ifndef GL_RGB
+#define GL_RGB                            0x1907
+#endif
+
+namespace QtWebEngineCore {
+#ifndef QT_NO_OPENGL
 class MailboxTexture : public QSGTexture, protected QOpenGLFunctions {
 public:
     MailboxTexture(const gpu::MailboxHolder &mailboxHolder, const QSize textureSize);
@@ -128,7 +142,7 @@ private:
 #endif
     friend class DelegatedFrameNode;
 };
-
+#endif // QT_NO_OPENGL
 class ResourceHolder {
 public:
     ResourceHolder(const cc::TransferableResource &resource);
@@ -202,6 +216,7 @@ static QSGNode *buildLayerChain(QSGNode *chainParent, const cc::SharedQuadState
     return layerChain;
 }
 
+#ifndef QT_NO_OPENGL
 static void waitChromiumSync(gl::TransferableFence *sync)
 {
     // Chromium uses its own GL bindings and stores in in thread local storage.
@@ -361,6 +376,7 @@ void MailboxTexture::fetchTexture(gpu::gles2::MailboxManager *mailboxManager)
 #endif
     }
 }
+#endif //QT_NO_OPENGL
 
 ResourceHolder::ResourceHolder(const cc::TransferableResource &resource)
     : m_resource(resource)
@@ -385,8 +401,12 @@ QSharedPointer<QSGTexture> ResourceHolder::initTexture(bool quadNeedsBlending, R
             QImage image(sharedBitmap->pixels(), m_resource.size.width(), m_resource.size.height(), format);
             texture.reset(apiDelegate->createTextureFromImage(image.copy()));
         } else {
+#ifndef QT_NO_OPENGL
             texture.reset(new MailboxTexture(m_resource.mailbox_holder, toQt(m_resource.size)));
             static_cast<MailboxTexture *>(texture.data())->setHasAlphaChannel(quadNeedsBlending);
+#else
+            Q_UNREACHABLE();
+#endif
         }
         m_texture = texture;
     }
@@ -422,12 +442,12 @@ RectClipNode::RectClipNode(const QRectF &rect)
 
 DelegatedFrameNode::DelegatedFrameNode()
     : m_numPendingSyncPoints(0)
-#if defined(USE_X11)
+#if defined(USE_X11) && !defined(QT_NO_OPENGL)
     , m_contextShared(true)
 #endif
 {
     setFlag(UsePreprocess);
-#if defined(USE_X11)
+#if defined(USE_X11) && !defined(QT_NO_OPENGL)
     QOpenGLContext *currentContext = QOpenGLContext::currentContext() ;
     QOpenGLContext *sharedContext = qt_gl_global_share_context();
     if (!QOpenGLContext::areSharing(currentContext, sharedContext)) {
@@ -449,6 +469,7 @@ DelegatedFrameNode::~DelegatedFrameNode()
 
 void DelegatedFrameNode::preprocess()
 {
+#ifndef QT_NO_OPENGL
     // With the threaded render loop the GUI thread has been unlocked at this point.
     // We can now wait for the Chromium GPU thread to produce textures that will be
     // rendered on our quads and fetch the IDs from the mailboxes we were given.
@@ -471,6 +492,7 @@ void DelegatedFrameNode::preprocess()
         // Proceed with the actual update.
         pair.second->updateTexture();
     }
+#endif
 }
 
 static YUVVideoMaterial::ColorSpace toQt(cc::YUVVideoDrawQuad::ColorSpace color_space)
@@ -614,12 +636,13 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
                 rectangleNode->setColor(toQt(scquad->color));
                 currentLayerChain->appendChildNode(rectangleNode);
                 break;
+#ifndef QT_NO_OPENGL
             } case cc::DrawQuad::DEBUG_BORDER: {
                 const cc::DebugBorderDrawQuad *dbquad = cc::DebugBorderDrawQuad::MaterialCast(quad);
                 QSGGeometryNode *geometryNode = new QSGGeometryNode;
 
                 QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
-                geometry->setDrawingMode(GL_LINE_LOOP);
+                geometry->setDrawingMode(QSGGeometry::DrawLineLoop);
                 geometry->setLineWidth(dbquad->width);
                 // QSGGeometry::updateRectGeometry would actually set the corners in the following order:
                 // top-left, bottom-left, top-right, bottom-right, leading to a nice criss cross, instead
@@ -638,6 +661,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
                 geometryNode->setFlags(QSGNode::OwnsGeometry | QSGNode::OwnsMaterial);
                 currentLayerChain->appendChildNode(geometryNode);
                 break;
+#endif
             } case cc::DrawQuad::TILED_CONTENT: {
                 const cc::TileDrawQuad *tquad = cc::TileDrawQuad::MaterialCast(quad);
                 ResourceHolder *resource = findAndHoldResource(tquad->resource_id(), resourceCandidates);
@@ -649,6 +673,7 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
                 textureNode->setTexture(initAndHoldTexture(resource, quad->ShouldDrawWithBlending(), apiDelegate));
                 currentLayerChain->appendChildNode(textureNode);
                 break;
+#ifndef QT_NO_OPENGL
             } case cc::DrawQuad::YUV_VIDEO_CONTENT: {
                 const cc::YUVVideoDrawQuad *vquad = cc::YUVVideoDrawQuad::MaterialCast(quad);
                 ResourceHolder *yResource = findAndHoldResource(vquad->y_plane_resource_id(), resourceCandidates);
@@ -671,9 +696,8 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
                 videoNode->setRect(toQt(quad->rect));
                 currentLayerChain->appendChildNode(videoNode);
                 break;
-            }
 #ifdef GL_OES_EGL_image_external
-            case cc::DrawQuad::STREAM_VIDEO_CONTENT: {
+            } case cc::DrawQuad::STREAM_VIDEO_CONTENT: {
                 const cc::StreamVideoDrawQuad *squad = cc::StreamVideoDrawQuad::MaterialCast(quad);
                 ResourceHolder *resource = findAndHoldResource(squad->resource_id(), resourceCandidates);
                 MailboxTexture *texture = static_cast<MailboxTexture *>(initAndHoldTexture(resource, quad->ShouldDrawWithBlending()));
@@ -684,9 +708,9 @@ void DelegatedFrameNode::commit(ChromiumCompositorData *chromiumCompositorData,
                 svideoNode->setTextureMatrix(toQt(squad->matrix.matrix()));
                 currentLayerChain->appendChildNode(svideoNode);
                 break;
-            }
-#endif
-            case cc::DrawQuad::SURFACE_CONTENT:
+#endif // GL_OES_EGL_image_external
+#endif // QT_NO_OPENGL
+            } case cc::DrawQuad::SURFACE_CONTENT:
                 Q_UNREACHABLE();
             default:
                 qWarning("Unimplemented quad material: %d", quad->material);
@@ -723,6 +747,7 @@ QSGTexture *DelegatedFrameNode::initAndHoldTexture(ResourceHolder *resource, boo
 
 void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxesToFetch)
 {
+#ifndef QT_NO_OPENGL
     QList<gl::TransferableFence> transferredFences;
     {
         QMutexLocker lock(&m_mutex);
@@ -818,11 +843,15 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe
         currentContext->makeCurrent(surface);
     }
 #endif
+#else
+    Q_UNUSED(mailboxesToFetch)
+#endif //QT_NO_OPENGL
 }
 
 
 void DelegatedFrameNode::pullTexture(DelegatedFrameNode *frameNode, MailboxTexture *texture)
 {
+#ifndef QT_NO_OPENGL
     gpu::gles2::MailboxManager *mailboxManager = mailbox_manager();
     gpu::SyncToken &syncToken = texture->mailboxHolder().sync_token;
     if (syncToken.HasData())
@@ -837,6 +866,10 @@ void DelegatedFrameNode::pullTexture(DelegatedFrameNode *frameNode, MailboxTextu
     }
     if (--frameNode->m_numPendingSyncPoints == 0)
         base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&DelegatedFrameNode::fenceAndUnlockQt, frameNode));
+#else
+    Q_UNUSED(frameNode)
+    Q_UNUSED(texture)
+#endif
 }
 
 void DelegatedFrameNode::fenceAndUnlockQt(DelegatedFrameNode *frameNode)
diff --git a/src/core/gl_context_qt.cpp b/src/core/gl_context_qt.cpp
index bbcd3554df08a504ac22d7606b796cd812e784a3..b1177a998edfb4d69f5c3e1a323c105d9c66bb9b 100644
--- a/src/core/gl_context_qt.cpp
+++ b/src/core/gl_context_qt.cpp
@@ -63,11 +63,15 @@ namespace {
 
 inline void *resourceForContext(const QByteArray &resource)
 {
+#ifndef QT_NO_OPENGL
     QOpenGLContext *shareContext = qt_gl_global_share_context();
     if (!shareContext) {
         qFatal("QWebEngine: OpenGL resource sharing is not set up in QtQuick. Please make sure to call QtWebEngine::initialize() in your main() function.");
     }
     return qApp->platformNativeInterface()->nativeResourceForContext(resource, shareContext);
+#else
+    return nullptr;
+#endif
 }
 
 inline void *resourceForIntegration(const QByteArray &resource)
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index 368ad48e28c0f798445a33253d9d1ecc8b27bd36..7fe8fb61228952a36295c3862906f092f5e70249 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -88,7 +88,9 @@
 #include <QFileInfo>
 #include <QGuiApplication>
 #include <QOffscreenSurface>
-#include <QOpenGLContext>
+#ifndef QT_NO_OPENGL
+# include <QOpenGLContext>
+#endif
 #include <QStringList>
 #include <QSurfaceFormat>
 #include <QVector>
@@ -96,9 +98,11 @@
 
 using namespace QtWebEngineCore;
 
+#ifndef QT_NO_OPENGL
 QT_BEGIN_NAMESPACE
 Q_GUI_EXPORT QOpenGLContext *qt_gl_global_share_context();
 QT_END_NAMESPACE
+#endif
 
 namespace {
 
@@ -115,6 +119,7 @@ void destroyContext()
     s_destroyed = true;
 }
 
+#ifndef QT_NO_OPENGL
 bool usingANGLE()
 {
 #if defined(Q_OS_WIN)
@@ -160,7 +165,7 @@ bool usingQtQuick2DRenderer()
     // Anything other than the default OpenGL device will need to render in 2D mode.
     return device != QLatin1String("default");
 }
-
+#endif //QT_NO_OPENGL
 #if defined(ENABLE_PLUGINS)
 void dummyGetPluginCallback(const std::vector<content::WebPluginInfo>&)
 {
@@ -318,6 +323,7 @@ WebEngineContext::WebEngineContext()
     GLContextHelper::initialize();
 
     const char *glType = 0;
+#ifndef QT_NO_OPENGL
     if (!usingANGLE() && !usingSoftwareDynamicGL() && !usingQtQuick2DRenderer()) {
         if (qt_gl_global_share_context()) {
             if (!strcmp(qt_gl_global_share_context()->nativeHandle().typeName(), "QEGLNativeContext")) {
@@ -365,6 +371,7 @@ WebEngineContext::WebEngineContext()
             }
         }
     }
+#endif
 
     if (glType)
         parsedCommandLine->AppendSwitchASCII(switches::kUseGL, glType);
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
index 9b5d90146164287e7fb7bc521e9dc667a0f5afd1..43011de0e2edb03aecc9aec90f3704023aa8ac8f 100644
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -103,6 +103,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
     format.setDepthBufferSize(24);
     format.setStencilBufferSize(8);
 
+#ifndef QT_NO_OPENGL
     QOpenGLContext *globalSharedContext = QOpenGLContext::globalShareContext();
     if (globalSharedContext) {
         QSurfaceFormat sharedFormat = globalSharedContext->format();
@@ -131,7 +132,7 @@ RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(Rende
 
     setFormat(format);
 #endif
-
+#endif
     setMouseTracking(true);
     setAttribute(Qt::WA_AcceptTouchEvents);
     setAttribute(Qt::WA_OpaquePaintEvent);