// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example proceduraltexture
    \ingroup quick3d-examples
    \title Qt Quick 3D - Procedural Texture Example
    \brief Demonstrates how to provide custom texture data from C++.
    \image proceduraltexture-example.jpg

    This example makes use of QQuick3DTextureData and \l{Texture::textureData}{the
    textureData property} of Texture to provide texture data generated from C++
    instead of loading it from a static asset.

    First we define a C++ class for our texture data. We make it a subclass
    of QQuick3DTextureData. This is not stricly necessary, since there are no
    virtual functions, but it is much more convenient to have everything in
    one class. We define the properties we are going to use, and add
    \l QML_NAMED_ELEMENT to make it available from QML:

    \snippet proceduraltexture/gradienttexture.h class definition
    \dots

    We add a function to update the texture. It uses \l QQuick3DTextureData::setSize,
    and \l QQuick3DTextureData::setFormat to configure the texture, and
    \l QQuick3DTextureData::setTextureData to set the image data:
    \snippet proceduraltexture/gradienttexture.cpp updateTexture

    The function \c generateTexture creates a QByteArray of the correct size, and
    fills it with image data:
    \snippet proceduraltexture/gradienttexture.cpp generateTexture

    We call \c updateTexture each time a property is changed:
    \snippet proceduraltexture/gradienttexture.cpp property

    Finally, we can use our new texture from QML:
    \snippet proceduraltexture/main.qml model

*/
