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

/*!
    \example multiviewport
    \title Qt 3D: Multi Viewport QML Example
    \ingroup qt3d-examples-qml
    \brief A QML example that demonstrates rendering a Scenegraph from multiple
    viewports.

    \image multiviewport-qml-example.jpg

    \e {Multi Viewport} renders a Scenegraph from the point of view of four
    virtual cameras into the four quadrants of a window. This is a common
    configuration for 3D CAD or modelling tools or could be adjusted to help
    with rendering a rear-view mirror in a car racing game or a CCTV camera
    display.

    For more information, see \l{A Multi Viewport FrameGraph}.

    \include examples-run.qdocinc

    \section1 Creating Multiple RenderViews

    Using the rules defined in \l {Framegraph Rules}, we construct five
    RenderView objects from the FrameGraph:

    \quotefromfile multiviewport/QuadViewportFrameGraph.qml
    \skipto Viewport {
    \printuntil /^\}/

    The \e {order is important}. If the ClearBuffers node were to be the last
    instead of the first, this would result in a black screen for the simple
    reason that everything would be cleared right after having been so carefully
    rendered. For a similar reason, it could not be used as the root of the
    FrameGraph as that would result in a call to clear the whole screen for each
    of our viewports.

    Although the declaration order of the FrameGraph is important, Qt 3D is able
    to process each RenderView in parallel as each RenderView is independent of
    the others for the purposes of generating a set of RenderCommands to be
    submitted whilst the RenderView's state is in effect.

    Qt 3D uses a task-based approach to parallelism which naturally scales up
    with the number of available cores. The RenderCommands for the RenderViews
    can be generated in parallel across many cores, and as long as we take care
    to submit the RenderViews in the correct order on the dedicated OpenGL
    submission thread, the resulting scene will be rendered correctly.
*/
