aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-08-23 14:39:09 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2021-08-25 09:56:36 +0200
commit1e8a99a071c3088dfdff9b9c486bf71a39533b45 (patch)
treea82eb128a521b0a9a2263c027225b1dd29deab3d /examples/quick
parent34cad4c1a952c163365870f93690a025ea33535f (diff)
Use add_shaders with CMake in some examples
Take the most obvious candidates, to which users typically turn when getting started with ShaderEffect or QSGMaterial: shadereffects scenegraph/custommaterial scenegraph/twotextureproviders As with the parent patch that ports and updates embeddedinwidgets and quickwidget/qquickviewcomparison to use the proper CMake machinery, we still need to keep the .qsb files for the sake of qmake. compile.bat and similar scripts are however removed now. With CMake the .qsb files are not needed and are autogenerated at build time. Once qmake support disappears from the examples, the .qsb files can be removed as well. Change-Id: I879354eef2e2179dcd268c9ae9f1402e1eaef379 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 266b93c9f8e7054ec572e47a8c48752381851231) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/scenegraph/custommaterial/CMakeLists.txt15
-rw-r--r--examples/quick/scenegraph/twotextureproviders/CMakeLists.txt17
-rw-r--r--examples/quick/scenegraph/twotextureproviders/shaders/compile.bat42
-rw-r--r--examples/quick/shadereffects/CMakeLists.txt22
-rwxr-xr-xexamples/quick/shadereffects/content/shaders/compile.bat56
5 files changed, 41 insertions, 111 deletions
diff --git a/examples/quick/scenegraph/custommaterial/CMakeLists.txt b/examples/quick/scenegraph/custommaterial/CMakeLists.txt
index d372b28bc9..21951727f9 100644
--- a/examples/quick/scenegraph/custommaterial/CMakeLists.txt
+++ b/examples/quick/scenegraph/custommaterial/CMakeLists.txt
@@ -19,6 +19,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Quick)
+find_package(Qt6 COMPONENTS ShaderTools)
qt_add_executable(custommaterial_declarative # special case
customitem.cpp customitem.h
@@ -40,13 +41,21 @@ qt_add_qml_module(custommaterial_declarative
VERSION 1.0
QML_FILES
main.qml
- RESOURCES
- shaders/mandelbrot.frag.qsb
- shaders/mandelbrot.vert.qsb
RESOURCE_PREFIX /scenegraph/custommaterial
NO_RESOURCE_TARGET_PATH
)
+qt6_add_shaders(custommaterial_declarative "shaders"
+ BATCHABLE
+ PRECOMPILE
+ OPTIMIZED
+ PREFIX
+ "/scenegraph/custommaterial/shaders"
+ FILES
+ "shaders/mandelbrot.vert"
+ "shaders/mandelbrot.frag"
+)
+
install(TARGETS custommaterial_declarative # special case
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quick/scenegraph/twotextureproviders/CMakeLists.txt b/examples/quick/scenegraph/twotextureproviders/CMakeLists.txt
index 9520e29d8b..fc103f406d 100644
--- a/examples/quick/scenegraph/twotextureproviders/CMakeLists.txt
+++ b/examples/quick/scenegraph/twotextureproviders/CMakeLists.txt
@@ -19,6 +19,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Qml)
find_package(Qt6 COMPONENTS Quick)
+find_package(Qt6 COMPONENTS ShaderTools)
qt_add_executable(twotextureproviders
main.cpp
@@ -40,14 +41,22 @@ qt_add_qml_module(twotextureproviders
VERSION 1.0
QML_FILES
main.qml
- RESOURCES
- shaders/checker.frag.qsb
- shaders/xorblender.frag.qsb
- shaders/xorblender.vert.qsb
RESOURCE_PREFIX /scenegraph/twotextureproviders
NO_RESOURCE_TARGET_PATH
)
+qt6_add_shaders(twotextureproviders "shaders"
+ BATCHABLE
+ PRECOMPILE
+ OPTIMIZED
+ PREFIX
+ "/scenegraph/twotextureproviders/shaders"
+ FILES
+ "shaders/xorblender.vert"
+ "shaders/xorblender.frag"
+ "shaders/checker.frag"
+)
+
install(TARGETS twotextureproviders
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quick/scenegraph/twotextureproviders/shaders/compile.bat b/examples/quick/scenegraph/twotextureproviders/shaders/compile.bat
deleted file mode 100644
index 99e0ff2a91..0000000000
--- a/examples/quick/scenegraph/twotextureproviders/shaders/compile.bat
+++ /dev/null
@@ -1,42 +0,0 @@
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-::
-:: Copyright (C) 2020 The Qt Company Ltd.
-:: Contact: https://www.qt.io/licensing/
-::
-:: This file is part of the QtQuick module of the Qt Toolkit.
-::
-:: $QT_BEGIN_LICENSE:LGPL$
-:: Commercial License Usage
-:: Licensees holding valid commercial Qt licenses may use this file in
-:: accordance with the commercial license agreement provided with the
-:: Software or, alternatively, in accordance with the terms contained in
-:: a written agreement between you and The Qt Company. For licensing terms
-:: and conditions see https://www.qt.io/terms-conditions. For further
-:: information use the contact form at https://www.qt.io/contact-us.
-::
-:: GNU Lesser General Public License Usage
-:: Alternatively, this file may be used under the terms of the GNU Lesser
-:: General Public License version 3 as published by the Free Software
-:: Foundation and appearing in the file LICENSE.LGPL3 included in the
-:: packaging of this file. Please review the following information to
-:: ensure the GNU Lesser General Public License version 3 requirements
-:: will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-::
-:: GNU General Public License Usage
-:: Alternatively, this file may be used under the terms of the GNU
-:: General Public License version 2.0 or (at your option) the GNU General
-:: Public license version 3 or any later version approved by the KDE Free
-:: Qt Foundation. The licenses are as published by the Free Software
-:: Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-:: included in the packaging of this file. Please review the following
-:: information to ensure the GNU General Public License requirements will
-:: be met: https://www.gnu.org/licenses/gpl-2.0.html and
-:: https://www.gnu.org/licenses/gpl-3.0.html.
-::
-:: $QT_END_LICENSE$
-::
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-qsb --glsl "100es,120,150" --hlsl 50 --msl 12 -c -O -o checker.frag.qsb checker.frag
-qsb -b --glsl "100es,120,150" --hlsl 50 --msl 12 -c -O -o xorblender.vert.qsb xorblender.vert
-qsb --glsl "100es,120,150" --hlsl 50 --msl 12 -c -O -o xorblender.frag.qsb xorblender.frag
diff --git a/examples/quick/shadereffects/CMakeLists.txt b/examples/quick/shadereffects/CMakeLists.txt
index bca1ec4d2a..fb0efd53a7 100644
--- a/examples/quick/shadereffects/CMakeLists.txt
+++ b/examples/quick/shadereffects/CMakeLists.txt
@@ -19,6 +19,7 @@ find_package(Qt6 COMPONENTS Core)
find_package(Qt6 COMPONENTS Gui)
find_package(Qt6 COMPONENTS Quick)
find_package(Qt6 COMPONENTS Qml)
+find_package(Qt6 COMPONENTS ShaderTools)
qt_add_executable(shadereffects
main.cpp
@@ -40,12 +41,6 @@ set(shadereffects_resource_files
"content/Slider.qml"
"content/face-smile.png"
"content/qt-logo.png"
- "content/shaders/blur.frag.qsb"
- "content/shaders/colorize.frag.qsb"
- "content/shaders/genie.vert.qsb"
- "content/shaders/outline.frag.qsb"
- "content/shaders/shadow.frag.qsb"
- "content/shaders/wobble.frag.qsb"
"shadereffects.qml"
)
@@ -56,6 +51,21 @@ qt6_add_resources(shadereffects "shadereffects"
${shadereffects_resource_files}
)
+qt6_add_shaders(shadereffects "shaders"
+ BATCHABLE
+ PRECOMPILE
+ OPTIMIZED
+ PREFIX
+ "/shadereffects/content/shaders"
+ FILES
+ "content/shaders/genie.vert"
+ "content/shaders/blur.frag"
+ "content/shaders/colorize.frag"
+ "content/shaders/outline.frag"
+ "content/shaders/shadow.frag"
+ "content/shaders/wobble.frag"
+)
+
install(TARGETS shadereffects
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/quick/shadereffects/content/shaders/compile.bat b/examples/quick/shadereffects/content/shaders/compile.bat
deleted file mode 100755
index e03cfde8d2..0000000000
--- a/examples/quick/shadereffects/content/shaders/compile.bat
+++ /dev/null
@@ -1,56 +0,0 @@
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-::
-:: Copyright (C) 2019 The Qt Company Ltd.
-:: Contact: https://www.qt.io/licensing/
-::
-:: This file is part of the examples of the Qt Toolkit.
-::
-:: $QT_BEGIN_LICENSE:BSD$
-:: Commercial License Usage
-:: Licensees holding valid commercial Qt licenses may use this file in
-:: accordance with the commercial license agreement provided with the
-:: Software or, alternatively, in accordance with the terms contained in
-:: a written agreement between you and The Qt Company. For licensing terms
-:: and conditions see https://www.qt.io/terms-conditions. For further
-:: information use the contact form at https://www.qt.io/contact-us.
-::
-:: BSD License Usage
-:: Alternatively, you may use this file under the terms of the BSD license
-:: as follows:
-::
-:: "Redistribution and use in source and binary forms, with or without
-:: modification, are permitted provided that the following conditions are
-:: met:
-:: * Redistributions of source code must retain the above copyright
-:: notice, this list of conditions and the following disclaimer.
-:: * Redistributions in binary form must reproduce the above copyright
-:: notice, this list of conditions and the following disclaimer in
-:: the documentation and/or other materials provided with the
-:: distribution.
-:: * Neither the name of The Qt Company Ltd nor the names of its
-:: contributors may be used to endorse or promote products derived
-:: from this software without specific prior written permission.
-::
-::
-:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-:: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-:: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-:: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-:: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-:: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-:: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-:: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-:: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-:: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-:: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-::
-:: $QT_END_LICENSE$
-::
-:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o blur.frag.qsb blur.frag
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o colorize.frag.qsb colorize.frag
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o outline.frag.qsb outline.frag
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o shadow.frag.qsb shadow.frag
-qsb --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o wobble.frag.qsb wobble.frag
-qsb -b --glsl "150,120,100 es" --hlsl 50 --msl 12 -c -O -o genie.vert.qsb genie.vert