summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/simple-cpp/doc/src/simple-cpp.qdoc
blob: 8f50cd835d3aff2fe74286ca97e7375545676853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \example simple-cpp
    \title Qt 3D: Simple C++ Example
    \ingroup qt3d-examples-cpp
    \brief A C++ application that demonstrates how to render a scene in Qt 3D.

    \image simple-cpp.png

    \e {Simple} demonstrates how to render a scene in Qt 3D.

    \include examples-run.qdocinc

    \section1 Setting Up the Scene

    We set up the scene in the \e main.cpp file.

    To be able to use the classes and functions in the Q3D Core, Q3D Render,
    Qt 3D Input, and Qt 3D Extras modules, we must include the classes:

    \quotefromfile simple-cpp/main.cpp
    \skipto Qt3DCore
    \printuntil QTorusMesh

    First, we set up the scene and specify its root entity:

    \skipto createScene()
    \printuntil {
    \skipto rootEntity
    \printuntil ;

    We specify the material to use for Phong rendering:

    \skipto QPhongMaterial
    \printuntil ;

    The root entity is just an empty shell and its behavior is defined by the
    components that it references. We specify the torus entity and its mesh,
    transform, and material components:

    \skipto torusEntity
    \printuntil material

    We also specify a sphere entity and its components:

    \skipto sphereEntity
    \printuntil material

    We use a property animation to animate the sphere transform.

    Finally, we initialize a Qt GUI application that uses a Qt 3D window:

    \skipto int
    \printuntil }
*/