diff options
Diffstat (limited to 'examples/vulkan/doc/src/hellovulkantriangle.qdoc')
-rw-r--r-- | examples/vulkan/doc/src/hellovulkantriangle.qdoc | 77 |
1 files changed, 48 insertions, 29 deletions
diff --git a/examples/vulkan/doc/src/hellovulkantriangle.qdoc b/examples/vulkan/doc/src/hellovulkantriangle.qdoc index f030d61578..bafa026ccd 100644 --- a/examples/vulkan/doc/src/hellovulkantriangle.qdoc +++ b/examples/vulkan/doc/src/hellovulkantriangle.qdoc @@ -1,29 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example hellovulkantriangle @@ -31,13 +7,56 @@ \ingroup examples-vulkan \title Hello Vulkan Triangle Example \brief Shows the basics of rendering with QVulkanWindow and the Vulkan API. + \examplecategory {Graphics} - The \e{Hello Vulkan Triangle Example} builds on \l hellovulkanwindow. This - time a full graphics pipeline is created, including a vertex and fragment - shader. This pipeline is then used to render a triangle. + The \e{Hello Vulkan Triangle Example} creates a full graphics pipeline, + including a vertex and fragment shader, to render a triangle. \image hellovulkantriangle.png + \section1 Startup + + Each Qt application using Vulkan will have to have a \c{Vulkan instance} + which encapsulates application-level state and initializes a Vulkan library. + + A QVulkanWindow must always be associated with a QVulkanInstance and hence + the example performs instance creation before the window. The + QVulkanInstance object must also outlive the window. + + \snippet hellovulkantriangle/main.cpp 0 + + The example enables validation layers, when supported. When the requested + layers are not present, the request will be ignored. Additional layers and + extensions can be enabled in a similar manner. + + \snippet hellovulkantriangle/main.cpp 1 + + Once the instance is ready, it is time to create a window. Note that \c w + lives on the stack and is declared after \c inst. + + \section1 The QVulkanWindow Subclass + + To add custom functionality to a QVulkanWindow, subclassing is used. This + follows the existing patterns from QOpenGLWindow and QOpenGLWidget. + However, QVulkanWindow utilizes a separate QVulkanWindowRenderer object. + + The QVulkanWindow subclass reimplements the factory function + QVulkanWindow::createRenderer(). This simply returns a new instance of the + QVulkanWindowRenderer subclass. In order to be able to access various + Vulkan resources via the window object, a pointer to the window is passed + and stored via the constructor. + + \snippet hellovulkantriangle/main.cpp 2 + + \section1 The Actual Rendering + + QVulkanWindow subclasses queue their draw calls in their reimplementation + of QVulkanWindowRenderer::startNextFrame(). Once done, they are required to + call back QVulkanWindow::frameReady(). The example has no asynchronous + command generation, so the frameReady() call is made directly from + startNextFrame(). To get continuous updates, the example simply invokes + QWindow::requestUpdate() in order to schedule a repaint. + The example also demonstrates multisample antialiasing. Based on the supported sample counts reported by QVulkanWindow::supportedSampleCounts() the example chooses between 8x, 4x, or no multisampling. Once configured |