From bf716cfdf0afecccdb1f2eabb2e6a172c620fbff Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 28 Oct 2014 12:48:17 +0200 Subject: Support for dynamic opengl builds. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTRD-3392 Change-Id: I786bbf5ee9252b92d43d02d6b88ed9b986b4a5eb Reviewed-by: Tomi Korpipää --- src/datavisualizationqml2/abstractdeclarative.cpp | 39 +++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'src/datavisualizationqml2') diff --git a/src/datavisualizationqml2/abstractdeclarative.cpp b/src/datavisualizationqml2/abstractdeclarative.cpp index b668c08f..51c254ec 100644 --- a/src/datavisualizationqml2/abstractdeclarative.cpp +++ b/src/datavisualizationqml2/abstractdeclarative.cpp @@ -19,7 +19,6 @@ #include "abstractdeclarative_p.h" #include "declarativetheme_p.h" #include "declarativerendernode_p.h" - #include #if defined(Q_OS_IOS) #include @@ -39,11 +38,7 @@ AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) : m_controller(0), m_contextWindow(0), m_renderMode(RenderIndirect), - #if defined(QT_OPENGL_ES_2) m_samples(0), - #else - m_samples(4), - #endif m_windowSamples(0), m_initialisedSize(0, 0), #ifdef USE_SHARED_CONTEXT @@ -56,7 +51,6 @@ AbstractDeclarative::AbstractDeclarative(QQuickItem *parent) : m_contextThread(0) { connect(this, &QQuickItem::windowChanged, this, &AbstractDeclarative::handleWindowChanged); - setAntialiasing(m_samples > 0); // Set contents to false in case we are in qml designer to make component look nice m_runningInDesigner = QGuiApplication::applicationDisplayName() == "Qml2Puppet"; @@ -279,6 +273,10 @@ void AbstractDeclarative::setSharedController(Abstract3DController *controller) Q_ASSERT(controller); m_controller = controller; + if (!m_controller->isOpenGLES()) + m_samples = 4; + setAntialiasing(m_samples > 0); + // Reset default theme, as the default C++ theme is Q3DTheme, not DeclarativeTheme3D. DeclarativeTheme3D *defaultTheme = new DeclarativeTheme3D; defaultTheme->d_ptr->setDefaultTheme(true); @@ -425,17 +423,15 @@ void AbstractDeclarative::setMsaaSamples(int samples) if (m_renderMode != RenderIndirect) { qWarning("Multisampling cannot be adjusted in this render mode"); } else { -#if defined(QT_OPENGL_ES_2) - if (samples > 0) - qWarning("Multisampling is not supported in OpenGL ES2"); -#else - if (m_samples != samples) { + if (m_controller->isOpenGLES()) { + if (samples > 0) + qWarning("Multisampling is not supported in OpenGL ES2"); + } else if (m_samples != samples) { m_samples = samples; setAntialiasing(m_samples > 0); emit msaaSamplesChanged(samples); update(); } -#endif } } @@ -577,24 +573,25 @@ void AbstractDeclarative::render() // Clear the background once per window as that is not done by default QQuickWindow *win = window(); activateOpenGLContext(win); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); if (m_renderMode == RenderDirectToBackground && !clearList.contains(win)) { clearList.append(win); QColor clearColor = win->color(); - glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), 1.0f); - glClear(GL_COLOR_BUFFER_BIT); + funcs->glClearColor(clearColor.redF(), clearColor.greenF(), clearColor.blueF(), 1.0f); + funcs->glClear(GL_COLOR_BUFFER_BIT); } if (isVisible()) { - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LESS); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); - glDisable(GL_BLEND); + funcs->glDepthMask(GL_TRUE); + funcs->glEnable(GL_DEPTH_TEST); + funcs->glDepthFunc(GL_LESS); + funcs->glEnable(GL_CULL_FACE); + funcs->glCullFace(GL_BACK); + funcs->glDisable(GL_BLEND); m_controller->render(); - glEnable(GL_BLEND); + funcs->glEnable(GL_BLEND); } doneOpenGLContext(win); } -- cgit v1.2.3