Redirect the default FBO correctly with QQuickWidget
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>
Mon, 1 Jun 2015 15:04:07 +0000 (17:04 +0200)
committerAntti Kokko <antti.kokko@theqtcompany.com>
Wed, 3 Jun 2015 16:20:59 +0000 (16:20 +0000)
commit07cd34e7380a425947f7a2912666595e797116d7
treeb37749a8e94aee8720b1d25d089597ae402d08f7
parentdb9be0a9d6195bc52415ce28d605ace149d02782
Redirect the default FBO correctly with QQuickWidget

Similarly to QOpenGLWidget, functions like QOpenGLFramebufferObject::bindDefault()
should bind the QQuickWidget's FBO, not 0, while rendering the scene graph.

This becomes particularly important on platforms with surfaceless context support.
Here offscreen surfaces are not backed by any surface. Therefore any OpenGL operation
accessing the current draw framebuffer with FBO 0 bound may potentially crash, as there
is no draw framebuffer at all.

The distance field glyph cache exhibits this issue when running with EGL on Mesa:
glViewport crashes when we render via QQuickWidget and the current framebuffer is reset
to 0. The problem goes away when the code changed is to use bindDefault() - as it should have
anyhow - and QQuickWidget is enhanced to communicate the "default" framebuffer to QOpenGLContext,
just like QOpenGLWidget does.

Task-number: QTBUG-46415
Task-number: QTBUG-43269
Change-Id: I35fe375a0870dadecc4a074dfdec122c6a4c92ab
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
src/quickwidgets/qquickwidget.cpp