From b6b1d5899415fef3231120c08c56a1dc2e246940 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 12 Nov 2019 10:57:15 +0100 Subject: Make QQuickFbo work with the OpenGL backend of QRhi So no matter if Quick goes directly to OpenGL, or via QRhi, QQuickFramebufferObject will still work. Also fix up the fboitem example to use a ShaderEffect that works with both rendering paths. With graphics APIs other than OpenGL the item will be empty, as QQuickFbo is not something we can support there. Task-number: QTBUG-79222 Change-Id: I52177d3a75f619f7075a2fc829573c17031eded1 Reviewed-by: Andy Nichols --- examples/quick/scenegraph/fboitem/fboitem.qrc | 2 ++ examples/quick/scenegraph/fboitem/main.qml | 15 +------------- .../scenegraph/fboitem/shaders/+qsb/checker.frag | Bin 0 -> 1615 bytes .../quick/scenegraph/fboitem/shaders/checker.frag | 14 +++++++++++++ .../scenegraph/fboitem/shaders/checker_rhi.frag | 22 +++++++++++++++++++++ 5 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 examples/quick/scenegraph/fboitem/shaders/+qsb/checker.frag create mode 100644 examples/quick/scenegraph/fboitem/shaders/checker.frag create mode 100644 examples/quick/scenegraph/fboitem/shaders/checker_rhi.frag (limited to 'examples/quick') diff --git a/examples/quick/scenegraph/fboitem/fboitem.qrc b/examples/quick/scenegraph/fboitem/fboitem.qrc index 9d9db70654..eeb5c36afd 100644 --- a/examples/quick/scenegraph/fboitem/fboitem.qrc +++ b/examples/quick/scenegraph/fboitem/fboitem.qrc @@ -1,5 +1,7 @@ main.qml + shaders/checker.frag + shaders/+qsb/checker.frag diff --git a/examples/quick/scenegraph/fboitem/main.qml b/examples/quick/scenegraph/fboitem/main.qml index 92fa99e847..1f1829deda 100644 --- a/examples/quick/scenegraph/fboitem/main.qml +++ b/examples/quick/scenegraph/fboitem/main.qml @@ -67,20 +67,7 @@ Item { property size pixelSize: Qt.size(width / tileSize, height / tileSize); - fragmentShader: - " - uniform lowp vec4 color1; - uniform lowp vec4 color2; - uniform highp vec2 pixelSize; - varying highp vec2 qt_TexCoord0; - void main() { - highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize)); - if (tc.x != tc.y) - gl_FragColor = color1; - else - gl_FragColor = color2; - } - " + fragmentShader: "qrc:/scenegraph/fboitem/shaders/checker.frag" } Renderer { diff --git a/examples/quick/scenegraph/fboitem/shaders/+qsb/checker.frag b/examples/quick/scenegraph/fboitem/shaders/+qsb/checker.frag new file mode 100644 index 0000000000..5037899d19 Binary files /dev/null and b/examples/quick/scenegraph/fboitem/shaders/+qsb/checker.frag differ diff --git a/examples/quick/scenegraph/fboitem/shaders/checker.frag b/examples/quick/scenegraph/fboitem/shaders/checker.frag new file mode 100644 index 0000000000..044b3bad58 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/shaders/checker.frag @@ -0,0 +1,14 @@ +uniform lowp vec4 color1; +uniform lowp vec4 color2; +uniform highp vec2 pixelSize; + +varying highp vec2 qt_TexCoord0; + +void main() +{ + highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize)); + if (tc.x != tc.y) + gl_FragColor = color1; + else + gl_FragColor = color2; +} diff --git a/examples/quick/scenegraph/fboitem/shaders/checker_rhi.frag b/examples/quick/scenegraph/fboitem/shaders/checker_rhi.frag new file mode 100644 index 0000000000..1e4131d026 --- /dev/null +++ b/examples/quick/scenegraph/fboitem/shaders/checker_rhi.frag @@ -0,0 +1,22 @@ +#version 440 + +layout(std140, binding = 0) uniform buf { + mat4 qt_Matrix; + float qt_Opacity; + + vec4 color1; + vec4 color2; + vec2 pixelSize; +} ubuf; + +layout(location = 0) in vec2 qt_TexCoord0; +layout(location = 0) out vec4 fragColor; + +void main() +{ + vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * ubuf.pixelSize)); + if (tc.x != tc.y) + fragColor = ubuf.color1; + else + fragColor = ubuf.color2; +} -- cgit v1.2.3