Commit Graph

225 Commits

Author SHA1 Message Date
Laszlo Agocs 266b93c9f8 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.

Pick-to: 6.2
Change-Id: I879354eef2e2179dcd268c9ae9f1402e1eaef379
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 13:51:52 +02:00
Craig Scott a86fd709dd Update quick examples to new QML CMake API
This is a pre-requisite to being able to make
qt6_qml_type_registration() an internal rather than public command.
Not all examples have been updated, only those that were using the
qt6_qml_type_registration() command.

Task-number: QTBUG-95093
Pick-to: 6.2
Change-Id: I3f1814a29af608461daa90477eca0aa2304eb9d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-24 16:08:21 +10:00
Joerg Bornemann b4ab58d791 Raise cmake_minimum_required to VERSION 3.16 in examples
Pick-to: 6.2
Task-number: QTBUG-95636
Change-Id: I9f76b787533dad1c469fbb8c69df6c27b20a9aa3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-08-17 13:48:14 +02:00
Ulf Hermann fff8d6120a Use "= default" rather than empty bodies for ctors and dtors
Change-Id: Idef0ebaa0074e1e4b6b74d20bd6c70cb22a04f93
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2021-07-01 08:34:58 +02:00
Ulf Hermann 91e7009aec Use "auto" as type when initializing using "new"
The type is immediately visible from the right hand side then.

Change-Id: Ifc1a15e3eea9b5a91ff8647f759d207a0ee221b8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-07-01 08:34:54 +02:00
Ulf Hermann 83859221c1 Initialize members in declaration rather than ctor
Change-Id: I084a6865ae37c6612fbcfd44a233234f05e38814
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:17:12 +02:00
Ulf Hermann 213b890899 Add missing "override" keywords
Our examples should follow best practices.

Change-Id: Ice90a818ae46e921b421e8d297806d8f7200294b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:17:01 +02:00
Ulf Hermann b200fbe213 Do not call QGuiApplication::exec() on an instance
It's a static method. It should be called statically.

Change-Id: I15fc8948988b0a2c0a30f8699949e06c66d92fdf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-06-30 14:16:55 +02:00
Ulf Hermann 1629fa0c6c Use nullptr rather than 0 for null pointers
Change-Id: I2921298ad2e04001bdee8824c56f01c203efb7d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-06-30 14:16:49 +02:00
Craig Scott 2422dd5a7a Switch examples to build as isolated sub-builds
Task-number: QTBUG-90820
Change-Id: Id9157526898ba72cb64ee8256639b37357f7bacf
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-05-27 21:08:14 +10:00
Laszlo Agocs 21d9cd844e Fix custommaterial example with OpenGL
The member names in the "uniform block" (which is in practice
mapped to a struct uniform with GLSL) must match between the
vertex and fragment shaders, even if the member is not used in
one of the shaders. This is because OpenGL/GLSL's interface
matching rules, which would cause the shader program fail to
link due to a mismatch in the structs in the two shaders.

Pick-to: 6.1 6.0
Change-Id: I9a928b4b20fdff14530c16a93a52967ce6c328a3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-02-19 10:17:08 +01:00
Friedemann Kleint 203acb1955 Fix building the d3d11underqml example with MinGW
Fix format mismatch
qtdeclarative/examples/quick/scenegraph/d3d11underqml/d3d11squircle.cpp:369:16: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'HRESULT' {aka 'long int'} [-Werror=format=]
          qFatal("Failed to create buffer: 0x%x", hr);
by casting to uint (as is done in an existing qWarning()).

Pick-to: 6.0
Change-Id: I9bed3066936af8a1831b695a76d40989a834fde9
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-11-26 20:29:37 +01:00
Topi Reinio 0b12055548 Doc: Fix documentation warnings for Qt Quick
- Remove links to modules and examples that are not part of Qt 6.
- Remove links to entities marked as \internal
- Add missing enum value and QML property docs where it's trivial
  to do so.

Task-number: QTBUG-88156
Change-Id: I10a1c7bcc5fe0e2354ea69eaf24930362edb7415
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-11-05 09:00:48 +01:00
Alexandru Croitor 20d5e2d7ef CMake: Regenerate examples to set the WIN32_EXECUTABLE property
As well as the MACOSX_BUNDLE properties as necessary.

Task-number: QTBUG-87664
Task-number: QTBUG-86827
Change-Id: I46769fb543acb2cbeba122470b5e44ad478fbe4e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-26 23:38:39 +01:00
Alexandru Croitor 903252b240 CMake: Regenerate examples to use qt_add_executable
Task-number: QTBUG-87661
Change-Id: Ie5bba408000211b24694aa0143bdf79c4a298f42
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2020-10-20 09:32:34 +02:00
Tor Arne Vestbø 43dbc7cbd1 Adapt to platform API rename
Change-Id: I1f2171e18ec3df71f7eaec1be0e0e0d1442a3860
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-10-09 09:03:20 +02:00
Ulf Hermann b030b4a1f2 examples: include QQuickWindow in squircle headers
This is required because QQuickWindow is passed as a signal parameter.

Change-Id: Ied10beded7253558d080af4806d1b95880bf2d98
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-09-13 08:15:15 +02:00
Laszlo Agocs df40607e8a Make twotextureproviders example functional again
Change-Id: I6a317fc8628b902e535a31daf4a3886fc87d08bc
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-07 12:38:25 +02:00
Laszlo Agocs 6cb48cb1da Regenerate graph example shaders
Change-Id: Id4fe4d0e177180fadd10f34b9ebad17c71e40314
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-07 12:38:23 +02:00
Laszlo Agocs 23ad0953ab Add CMake project file for custommaterial example
The name conflicts with a Quick3D example so try to use the same
approach as it was done for customgeometry.

Task-number: QTBUG-86205
Change-Id: Ie01cd6c0118d512b2f45d4c6e782ec6639e052c6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-07 11:48:26 +02:00
Laszlo Agocs 6f2f198aff Remove old GLSL code from fboitem example
There is no OpenGL path anymore in Qt 6, no point using file selectors.

Change-Id: I4b7afbbb193dfe1a6e912a909babab0aeb8dcdda
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-09-07 09:43:08 +02:00
Tor Arne Vestbø d0eb261836 Remove use of deprecated High-DPI application attributes
Change-Id: Ibfb50fdcbb51ba93d6e5d11f9e8ce0e7b3bfde79
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2020-09-02 17:17:33 +02:00
Sze Howe Koh fd105380eb Doc: Capitalize "GUI" correctly
Pick-to: 5.15
Change-Id: I2230e2dcb7bc2497b5dbe71a22c21d84176b5e57
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
2020-08-30 09:59:51 +08:00
Alexandru Croitor a09e4c1aa9 CMake: Rename example conflicting with qtquick3d
Fixes: QTBUG-86205
Change-Id: I38992501abb86a4328527283ad8924ec886ea8c8
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-25 15:40:05 +02:00
Laszlo Agocs 28005c0c03 Switch to MTLTexture protocol in QSGTexture native access
Now only available from ObjC code.

Change-Id: I88df6c8839fc660ffd2b8e88a789ca73a9d4accd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-04 14:29:30 +02:00
Laszlo Agocs fb96109bbc Add type safe native texture accessors
Following the pattern from QtGui.

Task-number: QTBUG-85239
Change-Id: I07b4456028d0f45223ad10e55ce65f423bab6a9b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-08-03 16:32:30 +02:00
Jarek Kobus dd71c43b97 Use QList instead of QVector
Task-number: QTBUG-84469
Change-Id: I4c3353c00a566023503fbc178ba8454391dc334c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-06-25 07:54:07 +02:00
Paul Olav Tvete 2be6c85b80 New custom material example
Fixes: QTBUG-78577
Change-Id: I280ffeda4bba1a9c170feb1ffa4b6c95eb0e6d28
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-24 19:48:45 +02:00
Laszlo Agocs 4e266103ad Rename setSceneGraphBackend to setGraphicsApi
...and fix up the docs.

The string-based setSceneGraphBackend() stays of course (the docs have
been enhanced, however). The GraphicsApi enum-based overload is now
renamed to setGraphicsApi().

Using the same name for both functions is a historical artifact, reflecting
the evolution (5.0 - 5.8 - 5.14). In 6.0 we can give it a more appropriate
name, since it does not have much to do with "backends" from the user's
perspective.

Change-Id: Id75dbf81f50a148797e5b5de9be4000153737473
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-06-22 16:10:52 +02:00
Laszlo Agocs a86febf876 Fix GL_ constant usage in examples
Change-Id: Iecfa47845edb78928b388d150a3229f8c7a93d5d
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
2020-06-17 17:42:02 +02:00
Eskil Abrahamsen Blomfeldt 90bf30376c Anisotropic antialiasing for distance field text
For perspective transforms, we need to find the sample
range in the glyph cache per pixel. We can do this by
getting the gradient of the distance field at the
specific pixel.

This will ensure proper antialiasing with any
projection, but has the limitation that when glyph contours
become thinner than a pixel, they may disappear or become
too emphasized, because the hardware-gradient - based on
neighbouring fragments - is not reliable at that scale.
So we should only default to this when we detect that the
text is child of a 3D scene.

To make this smooth, we need to know the mode of the renderer
when creating the shader. So QSGMaterial::createShader()
now takes a render mode that we can use to customize behavior
based on whether it is rendering into a 2D or 3D scene.

[ChangeLog][QtQuick] The QSGMaterial::createShader() virtual
function has been extended to take a render mode argument,
which can be used for any customizations needed in the case
where the shader will be used in combination with 3D perspective
transformations.

Fixes: QTBUG-84695
Change-Id: I5a18a4edbdfa07e8f9d506c42bb20e8eb580927d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-15 10:20:21 +02:00
Laszlo Agocs 69c7ed97c2 fboitem example: Request OpenGL explicitly
It wouldn't render otherwise.

Change-Id: I185459f2eccdffac4f7d7968e48aab4141e0908c
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-06-12 12:24:10 +02:00
Laszlo Agocs de45522283 openglunderqml example: remove unnecessary resetOpenGLState call
Also request the OpenGL RHI backend explicitly, like all the other
similar examples (d3d11underqml, and so on) do.

Calling resetOpenGLState() in this example is pointless because it
happens before returning from the custom rendering function, and the
endExternalCommands() call achieves the same internally, i.e. the rhi
will know that cached state cannot be used anymore. There are other
valid uses cases for resetOpenGLState() but this example does not have
those.

Change-Id: Ifa7861b80c29c174d02cfe37fe8ef8eed7344195
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-06-11 18:13:59 +02:00
Jonas Karlsson 1ca74842e8 Remove rendernode and opengltextureinthread examples
Task-Id: QTBUG-84623
Change-Id: I786a7a8ee256d8c395dd0e828213c5d137ba20dc
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-06-10 12:51:53 +02:00
Laszlo Agocs c167fd58c2 Enable Metal-based scenegraph examples
Change-Id: Ib2734fb10feaac106bb6483a8a361c7b35af3348
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-06-10 07:18:06 +02:00
Laszlo Agocs b87b3d3d43 Make QSGMaterialRhiShader become QSGMaterialShader
After a symbiotic relationship in Qt 5.14 and 5.15, it is time for
QSGMaterialRhiShader to devour its older sibling and take its place.

This makes the direct OpenGL rendering path disfunctional. All
QSGMaterial Qt 6 TODOs are solved, the API is clean and straightforward
again: a QSGMaterial creates a QSGMaterialShader, no special flags and
options needed. (it's just that QSGMaterialShader now has a slightly
different API)

Task-number: QTBUG-79268
Task-number: QTBUG-82997
Change-Id: I545ca8d796c5535e81957c706e7832133be15b7d
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-06-02 15:16:46 +02:00
Alexandru Croitor a7c7e7ceaa CMake: Don't install .qmltypes for Qt tests, examples and tools
that don't have an explicit QT_QML_MODULE_INSTALL_DIR path
specified. We don't want to pollute the Qt qml import path with
these files.

Task-number: QTBUG-84403
Change-Id: I768267e0e79daa8090d882c301648cce14e1a809
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-05-29 10:01:40 +02:00
Alexandru Croitor 965984771d CMake: Regenerate qtdeclarative/examples
Includes
- new example installation paths
- one case of QT_QMLTYPES_FILENAME addition

Change-Id: I24423da9b04b6ecc8445017fa35f148dd43b1829
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-05-29 10:01:22 +02:00
Laszlo Agocs 756c4c9e6d Avoid truncating in QSGMaterial::compare() implementations
The Qt 5.0 pattern of subtracting pointers and returning them is not
suitable (on 64-bit archs) since the return type is an int.

There is also QSGTexture::comparisonKey() now which is a qint64.

Just return -1 and 1 as appropriate.

Change-Id: Iaf3377b484a8c4b19b0960f1e8def05e4fa68ce7
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-05-27 15:39:30 +02:00
Laszlo Agocs 08f56c9830 Adjust QSGTexture comparisonKey type
The original choice was int, simply following textureId(). This was later
deemed insufficient: instead of a GLuint, the value is now often a 64-bit
value (on 64 bit systems), based on a pointer, since the identity of a texture
in the RHI world is the QRhiTexture* itself. In a custom texture implementation
it is likely that the value here is the value of a native object handle, either
a pointer or some 32 or 64 bit integer.

Inspired by the recent QSGTexture::NativeTexture struct change (void* -> quint64),
switch to a qint64 which is big enough to hold all these without truncation.

We choose a signed value here, in order to allow for the following pattern that
is widespread in material compare() implementations:
if (qint64 diff = m_texture->comparisonKey() - other->texture()->comparisonKey())
  return diff;

Fixes: QTBUG-83769
Change-Id: I8bdae8cd835282358ded53b3703142b8f26e4400
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-05-27 11:19:25 +02:00
Eskil Abrahamsen Blomfeldt 5d4d598354 Adapt to changes in NativeTexture in qtbase
To make the API less error prone, we have changed the
void pointer to the texture handle to a 64-bit in
instead, since all handles are maximum 64-bit.

Task-number: QTBUG-78638
Change-Id: I9d995d6a883b3377f57d7c5b19d4bc4e15aa347b
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-05-25 13:39:32 +02:00
Laszlo Agocs de41077a57 Add missing CMake project for vulkantextureimport
...and enable vulkanunderqml and vulkantextureimport in the CMakeLists
one level up.

Change-Id: I91d659e028b0e7f53b5860bbfbdbb98c18e333c7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-05-25 10:15:25 +02:00
Laszlo Agocs 6ef31dfb48 Fix up the scenegraph/textureinthread example
Force OpenGL, remove the ShaderEffect (it serves no purpose in this
example) and remove deprecated API usage.

Finally, rename the example to opengltextureinthread.

Note that the example's performance is sub-par, but the same is true
with direct OpenGL.

Change-Id: I7eaa2349ffdb3d27bd9e8815d674e918bc709c03
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-05-18 16:09:55 +02:00
Laszlo Agocs e25bd7a3b7 Remove leftover legacy shader files in scenegraph example
Task-number: QTBUG-82997
Change-Id: Icc328394154d7b352c9f47184c2f906d5afa4d44
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-04-29 08:42:17 +02:00
Mitch Curtis 9fd4160307 QQuickItem: rename geometryChanged to geometryChange
This brings it in line with the existing convention in this and other
modules, where virtual handlers are named "nounChange"; e.g.
itemChange. Signals are named "nounChanged".

This also allows adding a geometryChanged signal, which would enable
users to listen to one signal for all changes to x/y/width/height.

[ChangeLog][QQuickItem] Renamed geometryChanged to geometryChange
in order to follow existing naming conventions and have consistency
with existing API, such as itemChange.

Task-number: QTBUG-82994
Change-Id: I0547358c796a0047982ccfbf2c38bab952e7a634
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-04-23 12:13:20 +02:00
Qt Forward Merge Bot 2812184e1b Merge remote-tracking branch 'origin/5.15' into dev
Conflicts:
	src/qml/jsruntime/qv4executablecompilationunit.cpp
	src/qml/jsruntime/qv4executablecompilationunit_p.h
	src/qml/qml/qqmlobjectcreator.cpp
	src/qml/qml/qqmlpropertycachecreator_p.h
	src/qml/qml/qqmltypecompiler.cpp
	src/qml/qml/qqmltypedata.cpp
	tests/auto/qml/qmlformat/tst_qmlformat.cpp
	tools/qmllint/scopetree.cpp
	src/qml/qml/qqmlapplicationengine_p.h

Adjusted tools/qmllint/findunqualified.cpp to use newer API

Change-Id: Ibfb4678ca39d626d47527265e3c96e43313873d4
2020-04-09 10:08:41 +02:00
Laszlo Agocs e2ac02e942 twotextureproviders example: rip out legacy OpenGL material impl
Leave only the RHI version in. Also add a temporary forcing of the RHI
rendering path for now. This will go away when purging the direct OpenGL
path in Qt Quick because RHI will be the default anyhow.

Now both graph and twotextureproviders follow the same structure and
approach, and together serve as a fairly good examples of creating custom
materials in the RHI world.

Change-Id: I4aafd440f70d13b8033fd4fdf0ecce71798c68d2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-04-07 17:09:12 +02:00
Laszlo Agocs d7a42f580c Update graph example CMake
Also update OTHER_FILES in the .pro although that's not strictly
required for building.

Change-Id: Ib48e64b298c1a7b1600ecd1f13580398679b72a2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-04-07 17:08:52 +02:00
Laszlo Agocs fd4f121fca Remove QSGSimpleMaterial
And port the graph example to QSGMaterial and the RHI. We will not anymore add a
direct OpenGL path (that would mean using QSGMaterialShader) for the example because
the upcoming purge renders that useless anyway.

Task-number: QTBUG-82988
Change-Id: I137575ed5df45b6bfc34a11d73dc5100945081c5
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-04-07 17:08:39 +02:00
Laszlo Agocs 02d35ec094 Remove sgengine from scenegraph examples CMake project file
Change-Id: Ifb2f986ec9d4fd0bfdd35f2e59d7d1d916ac2098
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-04-07 11:52:29 +02:00