1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qviewport.h"
5#include "qviewport_p.h"
6
7QT_BEGIN_NAMESPACE
8
9namespace Qt3DRender {
10
11QViewportPrivate::QViewportPrivate()
12 : QFrameGraphNodePrivate()
13 , m_normalizedRect(QRectF(0.0f, 0.0f, 1.0f, 1.0f))
14 , m_gamma(2.2f)
15{
16}
17
18/*!
19 \class Qt3DRender::QViewport
20 \inmodule Qt3DRender
21 \brief A viewport on the Qt3D Scene.
22 \since 5.7
23
24 \inherits Qt3DRender::QFrameGraphNode
25
26 Qt3DRender::QViewport of the scene specifies at which portion of the render surface Qt3D
27 is rendering to. Area outside the viewport is left untouched. It also controls global parameters
28 to the rendering in that viewport like gamma.
29 */
30
31/*!
32 \qmltype Viewport
33 \inqmlmodule Qt3D.Render
34 \since 5.7
35 \inherits FrameGraphNode
36 \instantiates Qt3DRender::QViewport
37 \brief A viewport on the Qt3D Scene.
38
39 Viewport of the scene specifies at which portion of the render surface Qt3D is
40 rendering to. Area outside the viewport is left untouched. It also controls global parameters
41 to the rendering in that viewport like gamma.
42 */
43
44/*!
45 \qmlproperty rect Viewport::normalizedRect
46
47 Specifies the normalised rectangle for the viewport, i.e. the viewport rectangle
48 is specified relative to the render surface size. Whole surface sized viewport
49 is specified as [0.0, 0.0, 1.0, 1.0], which is the default.
50 */
51
52/*!
53 \qmlproperty real Viewport::gamma
54
55 Specifies the gamma factor for the viewport. The default is 2.2 which should give proper result on most screens.
56 */
57
58/*!
59 Constructs QViewport with given \a parent.
60 */
61QViewport::QViewport(QNode *parent)
62 : QFrameGraphNode(*new QViewportPrivate, parent)
63{
64}
65
66/*! \internal */
67QViewport::~QViewport()
68{
69}
70
71/*! \internal */
72QViewport::QViewport(QViewportPrivate &dd, QNode *parent)
73 : QFrameGraphNode(dd, parent)
74{
75}
76
77
78QRectF QViewport::normalizedRect() const
79{
80 Q_D(const QViewport);
81 return d->m_normalizedRect;
82}
83
84float QViewport::gamma() const
85{
86 Q_D(const QViewport);
87 return d->m_gamma;
88}
89
90/*!
91 \property QViewport::normalizedRect
92
93 Specifies the normalised rectangle for the viewport, i.e. the viewport rectangle
94 is specified relative to the render surface size. Whole surface sized viewport
95 is specified as [0.0, 0.0, 1.0, 1.0], which is the default.
96 */
97void QViewport::setNormalizedRect(const QRectF &normalizedRect)
98{
99 Q_D(QViewport);
100 if (normalizedRect != d->m_normalizedRect) {
101 d->m_normalizedRect = normalizedRect;
102 emit normalizedRectChanged(normalizedRect);
103 }
104}
105
106/*!
107 \property QViewport::gamma
108
109 Specifies the gamma factor for the viewport. The default is 2.2 which should give proper result on most screens.
110 */
111void QViewport::setGamma(float gamma)
112{
113 Q_D(QViewport);
114 if (gamma != d->m_gamma) {
115 d->m_gamma = gamma;
116 emit gammaChanged(gamma);
117 }
118}
119
120} // namespace Qt3DRender
121
122QT_END_NAMESPACE
123
124#include "moc_qviewport.cpp"
125

source code of qt3d/src/render/framegraph/qviewport.cpp