diff options
author | Christian Strømme <christian.stromme@qt.io> | 2024-01-23 21:58:40 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-01-23 22:10:52 +0000 |
commit | 9d63f8ecaf511782bc9cf381f1943488d44251a1 (patch) | |
tree | 2cd4161e85ee545ff24b259d699d62eacc683b69 | |
parent | 009186db12aa8ac86b7fdc4d3fd7197226efb14f (diff) |
Doc: Improve the outline render extension documentation
Add missing steps for setting the extension property on the view and
clean up some wording.
Change-Id: I1d9143b1ca6055023e4759acdc645a8a40b3c762
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
(cherry picked from commit eb0cb9c102b27f1ce22b6696150354c17b8793ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
3 files changed, 20 insertions, 8 deletions
diff --git a/examples/quick3d/extensions/stenciloutline/Main.qml b/examples/quick3d/extensions/stenciloutline/Main.qml index cfd22213..88395b58 100644 --- a/examples/quick3d/extensions/stenciloutline/Main.qml +++ b/examples/quick3d/extensions/stenciloutline/Main.qml @@ -52,17 +52,17 @@ ApplicationWindow { } } + //! [1] View3D { id: view3d anchors.topMargin: 100 anchors.fill: parent - //! [extension property] extensions: [ OutlineRenderExtension { id: outlineRenderer outlineMaterial: outlineMaterial } ] - //! [extension property] + //! [1] PerspectiveCamera { id: camera @@ -111,6 +111,7 @@ ApplicationWindow { } } +//! [2] MouseArea { anchors.fill: view3d onClicked: (mouse)=> { @@ -118,4 +119,5 @@ ApplicationWindow { outlineRenderer.target = hit.objectHit } } +//! [2] } diff --git a/examples/quick3d/extensions/stenciloutline/doc/src/qtquick3d-examples-outline_extension.qdoc b/examples/quick3d/extensions/stenciloutline/doc/src/qtquick3d-examples-outline_extension.qdoc index bb835086..9fd6e980 100644 --- a/examples/quick3d/extensions/stenciloutline/doc/src/qtquick3d-examples-outline_extension.qdoc +++ b/examples/quick3d/extensions/stenciloutline/doc/src/qtquick3d-examples-outline_extension.qdoc @@ -13,8 +13,8 @@ The first step is to implement the front-end item by creating a new \l {QQuick3DRenderExtension}{Render Extension} item which exposes the properties needed to QML. - In this example we expose 3 properties, the \c {target model} we want to the outline to be applied to, the \c material we want to use - for the outline, and the scale we want to apply for the outline. + In this example we expose 3 properties, a \c target which takes the \l {QtQuick3D::Model}{model} we want to outline, + the \l {QtQuick3D::Material}{material} we want to use for the outline, and a \c scale value for adjusting the size of the outline. \snippet extensions/stenciloutline/outlinerenderextension.h extension front @@ -38,9 +38,19 @@ \snippet extensions/stenciloutline/outlinerenderextension.cpp extension back_prepareRender - When the engine is ready to record the rendering calls for our models then QSSGRenderExtension::render() will be called. - In this case, we can simply just just call QSSGRenderHelpers::renderRenderables() for the two models, they will then - be rendered just the same way as QtQuick3D would have done internally, only now with our changes. + When the engine is ready to record the rendering calls for our extension it wll call the virtual QSSGRenderExtension::render() function. + In this example we can simply call QSSGRenderHelpers::renderRenderables() for the two models, they will then + be rendered just the same way as QtQuick3D would have done internally, only this time with our settings. \snippet extensions/stenciloutline/outlinerenderextension.cpp extension back_render + + The \c OutlineRenderExtension is made active by adding it to the \l {QtQuick3D::View3D}{View3D's} + \l {QtQuick3D::View3D::extensions}{extensions} property. + + \snippet extensions/stenciloutline/Main.qml 1 + + Now when a \c model is picked we just need to set the picked \c model as the \c target for the \c OutlineRenderExtension + to have it rendered with an outline. + + \snippet extensions/stenciloutline/Main.qml 2 */ diff --git a/examples/quick3d/extensions/stenciloutline/outlinerenderextension.cpp b/examples/quick3d/extensions/stenciloutline/outlinerenderextension.cpp index c1766a4b..5bd1253b 100644 --- a/examples/quick3d/extensions/stenciloutline/outlinerenderextension.cpp +++ b/examples/quick3d/extensions/stenciloutline/outlinerenderextension.cpp @@ -79,7 +79,7 @@ bool OutlineRenderer::prepareData(QSSGFrameData &data) stencilPrepResult = QSSGRenderHelpers::commit(data, stencilPrepContext, stencilRenderables); outlinePrepResult = QSSGRenderHelpers::commit(data, outlinePrepContext, outlineRenderables); - // If there's someting to be rendered we return true. + // If there's something to be rendered we return true. const bool dataReady = (stencilPrepResult != QSSGPrepResultId::Invalid && outlinePrepResult != QSSGPrepResultId::Invalid); return dataReady; |