extern Q_GUI_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha);
bool QQuickWindowPrivate::defaultAlphaBuffer = false;
-bool QQuickWindowPrivate::defaultFormatInitialized = false;
-QSurfaceFormat QQuickWindowPrivate::defaultFormat;
void QQuickWindowPrivate::updateFocusItemTransform()
{
}
q->setSurfaceType(windowManager ? windowManager->windowSurfaceType() : QSurface::OpenGLSurface);
- q->setFormat(q->defaultFormat());
+ q->setFormat(sg->defaultSurfaceFormat());
animationController = new QQuickAnimatorController();
animationController->m_window = q;
\note All classes with QSG prefix should be used solely on the scene graph's
rendering thread. See \l {Scene Graph and Rendering} for more information.
- \sa {Scene Graph - OpenGL Under QML}
+ \section2 Context and surface formats
+ While it is possible to specify a QSurfaceFormat for every QQuickWindow by
+ calling the member function setFormat(), windows may also be created from
+ QML by using the Window and ApplicationWindow elements. In this case there
+ is no C++ code involved in the creation of the window instance, yet
+ applications may still wish to set certain surface format values, for
+ example to request a given OpenGL version or profile. Such applications can
+ call the static function QSurfaceFormat::setDefaultFormat() at startup. The
+ specified format will be used for all Quick windows created afterwards.
+
+ \sa {Scene Graph - OpenGL Under QML}
*/
/*!
In any application which expects to create translucent windows, it's necessary to set
this to true before creating the first QQuickWindow. The default value is false.
- \note This function affects the size of the alpha buffer in the format returned by
- defaultFormat(). Enabling alpha via this function and passing a format with alpha
- buffer size 8 to setDefaultFormat() are equivalent.
-
- \sa hasDefaultAlphaBuffer(), setDefaultFormat(), defaultFormat()
+ \sa hasDefaultAlphaBuffer()
*/
void QQuickWindow::setDefaultAlphaBuffer(bool useAlpha)
{
}
/*!
- \brief QQuickWindow::setDefaultFormat
- \since 5.4
- @brief Sets the global default surface format that is used for all new QQuickWindow instances.
-
- While it is possible to specify a QSurfaceFormat for every QQuickWindow by
- calling the member function setFormat(), windows may also be created from
- QML by using the Window and ApplicationWindow elements. In this case there
- is no C++ code involved in the creation of the window instance, yet
- applications may still wish to set certain surface format values, for
- example to request a given OpenGL version or profile. Such applications can
- call this static functions in main(). \a format will be used for all Quick
- windows created afterwards.
-
- \note The default value for the default format is not necessarily a
- default-constructed QSurfaceFormat. It may already have depth, stencil and alpha
- buffer sizes set. Unless there is a need to change all these sizes, the format should
- first be queried via defaultFormat() and the changes should be applied to that,
- instead of merely starting with a default-constructed QSurfaceFormat.
-
- \sa setFormat(), format(), defaultFormat()
- */
-void QQuickWindow::setDefaultFormat(const QSurfaceFormat &format)
-{
- QQuickWindowPrivate::defaultFormatInitialized = true;
- QQuickWindowPrivate::defaultFormat = format;
-}
-
-/*!
- \brief QQuickWindow::defaultFormat
- \since 5.4
-
- \return The global default surface format that is used for all QQuickWindow instances.
-
- \note This function requires a QGuiApplication or QApplication instance.
-
- \sa setDefaultFormat()
- */
-QSurfaceFormat QQuickWindow::defaultFormat()
-{
- if (!QQuickWindowPrivate::defaultFormatInitialized) {
- QQuickWindowPrivate::defaultFormatInitialized = true;
- QQuickWindowPrivate::defaultFormat = QSGRenderLoop::instance()->sceneGraphContext()->defaultSurfaceFormat();
- }
- return QQuickWindowPrivate::defaultFormat;
-}
-
-/*!
\brief QQuickWindow::glslVersion
\since 5.4
\return The OpenGL Shading Language version for this window.
OpenGL 2 style shaders. The most important for reusable components is to check for
core profiles since these do not accept shaders with the old syntax.
- \sa setFormat(), setDefaultFormat(), glslIsCoreProfile()
+ \sa setFormat(), glslIsCoreProfile()
*/
QString QQuickWindow::glslVersion() const
{
To retrieve more information about the shading language, use glslVersion().
- \sa glslVersion(), setFormat(), setDefaultFormat()
+ \sa glslVersion(), setFormat()
*/
bool QQuickWindow::glslIsCoreProfile() const
{
// least using some harmless settings to check that the global, static format is
// taken into account in the requested format.
- QSurfaceFormat savedDefaultFormat = QQuickWindow::defaultFormat();
+ QSurfaceFormat savedDefaultFormat = QSurfaceFormat::defaultFormat();
// Verify that depth and stencil are set, as they should be, unless they are disabled
// via environment variables.
- QVERIFY(savedDefaultFormat.depthBufferSize() >= 16);
- QVERIFY(savedDefaultFormat.stencilBufferSize() >= 8);
QSurfaceFormat format = savedDefaultFormat;
format.setSwapInterval(0);
format.setBlueBufferSize(8);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setOption(QSurfaceFormat::DebugContext);
- QQuickWindow::setDefaultFormat(format);
+ // Will not set depth and stencil. That should be added automatically,
+ // unless the are disabled (but they aren't).
+ QSurfaceFormat::setDefaultFormat(format);
QQuickWindow window;
window.show();
QCOMPARE(format.profile(), reqFmt.profile());
QCOMPARE(int(format.options()), int(reqFmt.options()));
- QQuickWindow::setDefaultFormat(savedDefaultFormat);
+ // Depth and stencil should be >= what has been requested. For real. But use
+ // the context since the window's surface format is only partially updated
+ // on most platforms.
+ QVERIFY(window.openglContext()->format().depthBufferSize() >= 16);
+ QVERIFY(window.openglContext()->format().stencilBufferSize() >= 8);
+
+ QSurfaceFormat::setDefaultFormat(savedDefaultFormat);
}
void tst_qquickwindow::glslVersion()