1// Copyright (C) 2016 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
5#include "qtexturedata.h"
6
7QT_BEGIN_NAMESPACE
8
9namespace Qt3DRender {
10
11/*!
12 * \class Qt3DRender::QTextureData
13 * \inheaderfile Qt3DRender/QTextureData
14 * \brief The QTextureData class stores texture information such as
15 * the target, height, width, depth, layers, wrap, and if mipmaps are enabled.
16 * \since 5.7
17 * \inmodule Qt3DRender
18 */
19
20class QTextureDataPrivate
21{
22public:
23 QAbstractTexture::Target m_target;
24 QAbstractTexture::TextureFormat m_format = QAbstractTexture::NoFormat;
25 int m_width = 0;
26 int m_height = 0;
27 int m_depth = 0;
28 int m_layers = 0;
29 bool m_autoMipMap = false;
30 float m_maximumAnisotropy = 0.0f;
31 QAbstractTexture::Filter m_minFilter;
32 QAbstractTexture::Filter m_magFilter;
33 QTextureWrapMode::WrapMode m_wrapModeX;
34 QTextureWrapMode::WrapMode m_wrapModeY;
35 QTextureWrapMode::WrapMode m_wrapModeZ;
36 QAbstractTexture::ComparisonFunction m_comparisonFunction;
37 QAbstractTexture::ComparisonMode m_comparisonMode;
38 QList<QTextureImageDataPtr> m_imagesData;
39
40};
41
42/*!
43 * Creates a new QTextureData
44 * instance.
45 */
46QTextureData::QTextureData()
47 : d_ptr(new QTextureDataPrivate())
48{
49}
50
51/*!
52 * \internal
53 */
54QTextureData::~QTextureData()
55{
56 delete d_ptr;
57}
58
59/*!
60 * Returns the texture data target.
61 */
62QAbstractTexture::Target QTextureData::target() const
63{
64 Q_D(const QTextureData);
65 return d->m_target;
66}
67
68/*!
69 * Sets the target texture to \a target.
70 */
71void QTextureData::setTarget(QAbstractTexture::Target target)
72{
73 Q_D(QTextureData);
74 d->m_target = target;
75}
76
77/*!
78 * Returns the texture format
79 */
80QAbstractTexture::TextureFormat QTextureData::format() const
81{
82 Q_D(const QTextureData);
83 return d->m_format;
84}
85
86/*!
87 * Sets the texture format to \a format.
88 */
89void QTextureData::setFormat(QAbstractTexture::TextureFormat format)
90{
91 Q_D(QTextureData);
92 d->m_format = format;
93}
94
95/*!
96 * Returns the texture width.
97 */
98int QTextureData::width() const
99{
100 Q_D(const QTextureData);
101 return d->m_width;
102}
103
104/*!
105 * Sets the texture width to \a width.
106 */
107void QTextureData::setWidth(int width)
108{
109 Q_D(QTextureData);
110 d->m_width = width;
111}
112
113/*!
114 * Returns the texture height.
115 */
116int QTextureData::height() const
117{
118 Q_D(const QTextureData);
119 return d->m_height;
120}
121
122/*!
123 * Sets the target height to \a height.
124 */
125void QTextureData::setHeight(int height)
126{
127 Q_D(QTextureData);
128 d->m_height = height;
129}
130
131/*!
132 * Returns the texture depth.
133 */
134int QTextureData::depth() const
135{
136 Q_D(const QTextureData);
137 return d->m_depth;
138}
139
140/*!
141 * Sets the texture depth to \a depth
142 */
143void QTextureData::setDepth(int depth)
144{
145 Q_D(QTextureData);
146 d->m_depth = depth;
147}
148
149/*!
150 * Returns the texture layers.
151 */
152int QTextureData::layers() const
153{
154 Q_D(const QTextureData);
155 return d->m_layers;
156}
157
158/*!
159 * Sets the texture layers to \a layers.
160 */
161void QTextureData::setLayers(int layers)
162{
163 Q_D(QTextureData);
164 d->m_layers = layers;
165}
166
167/*!
168 * Returns whether the texture has auto mipmap generation enabled.
169 */
170bool QTextureData::isAutoMipMapGenerationEnabled() const
171{
172 Q_D(const QTextureData);
173 return d->m_autoMipMap;
174}
175
176/*!
177 * Sets whether the texture has automatic mipmap generation enabled, to \a autoMipMap.
178 */
179void QTextureData::setAutoMipMapGenerationEnabled(bool autoMipMap)
180{
181 Q_D(QTextureData);
182 d->m_autoMipMap = autoMipMap;
183}
184
185/*!
186 * Returns the current maximum anisotropy.
187 */
188float QTextureData::maximumAnisotropy() const
189{
190 Q_D(const QTextureData);
191 return d->m_maximumAnisotropy;
192}
193
194/*!
195 * Sets the maximum anisotropy to \a maximumAnisotropy.
196 */
197void QTextureData::setMaximumAnisotropy(float maximumAnisotropy)
198{
199 Q_D(QTextureData);
200 d->m_maximumAnisotropy = maximumAnisotropy;
201}
202
203/*!
204 * Returns the current minification filter.
205 */
206QAbstractTexture::Filter QTextureData::minificationFilter() const
207{
208 Q_D(const QTextureData);
209 return d->m_minFilter;
210}
211
212/*!
213 * Sets the minification filter to \a filter.
214 */
215void QTextureData::setMinificationFilter(QAbstractTexture::Filter filter)
216{
217 Q_D(QTextureData);
218 d->m_minFilter = filter;
219}
220
221/*!
222 * Returns the current magnification filter.
223 */
224QAbstractTexture::Filter QTextureData::magnificationFilter() const
225{
226 Q_D(const QTextureData);
227 return d->m_magFilter;
228}
229
230/*!
231 * Sets the magnification filter to \a filter.
232 */
233void QTextureData::setMagnificationFilter(QAbstractTexture::Filter filter)
234{
235 Q_D(QTextureData);
236 d->m_magFilter = filter;
237}
238
239/*!
240 * Returns the current wrap mode X.
241 */
242QTextureWrapMode::WrapMode QTextureData::wrapModeX() const
243{
244 Q_D(const QTextureData);
245 return d->m_wrapModeX;
246}
247
248/*!
249 * Sets the wrap mode X to \a wrapModeX.
250 */
251void QTextureData::setWrapModeX(QTextureWrapMode::WrapMode wrapModeX)
252{
253 Q_D(QTextureData);
254 d->m_wrapModeX = wrapModeX;
255}
256
257/*!
258 * Returns the current wrap mode Y.
259 */
260QTextureWrapMode::WrapMode QTextureData::wrapModeY() const
261{
262 Q_D(const QTextureData);
263 return d->m_wrapModeY;
264}
265
266/*!
267 * Sets the wrap mode Y to \a wrapModeY.
268 */
269void QTextureData::setWrapModeY(QTextureWrapMode::WrapMode wrapModeY)
270{
271 Q_D(QTextureData);
272 d->m_wrapModeY = wrapModeY;
273}
274
275/*!
276 * Returns the current wrap mode Z.
277 */
278QTextureWrapMode::WrapMode QTextureData::wrapModeZ() const
279{
280 Q_D(const QTextureData);
281 return d->m_wrapModeZ;
282}
283
284/*!
285 * Sets the wrap mode Z to \a wrapModeZ.
286 */
287void QTextureData::setWrapModeZ(QTextureWrapMode::WrapMode wrapModeZ)
288{
289 Q_D(QTextureData);
290 d->m_wrapModeZ = wrapModeZ;
291}
292
293/*!
294 * Returns the current comparison function.
295 */
296QAbstractTexture::ComparisonFunction QTextureData::comparisonFunction() const
297{
298 Q_D(const QTextureData);
299 return d->m_comparisonFunction;
300}
301
302/*!
303 * Sets the comparison function to \a comparisonFunction.
304 */
305void QTextureData::setComparisonFunction(QAbstractTexture::ComparisonFunction comparisonFunction)
306{
307 Q_D(QTextureData);
308 d->m_comparisonFunction = comparisonFunction;
309}
310
311/*!
312 * Returns the current comparison mode.
313 */
314QAbstractTexture::ComparisonMode QTextureData::comparisonMode() const
315{
316 Q_D(const QTextureData);
317 return d->m_comparisonMode;
318}
319
320/*!
321 * Sets the comparison mode to \a comparisonMode.
322 */
323void QTextureData::setComparisonMode(QAbstractTexture::ComparisonMode comparisonMode)
324{
325 Q_D(QTextureData);
326 d->m_comparisonMode = comparisonMode;
327}
328
329/*!
330 * Returns the data of the images used by this texture.
331 */
332QList<QTextureImageDataPtr> QTextureData::imageData() const
333{
334 Q_D(const QTextureData);
335 return d->m_imagesData;
336}
337
338/*!
339 * Adds an extra image layer to the texture using \a imageData.
340 *
341 * \note The texture image should be loaded with the size specified on the texture.
342 * However, if no size is specified, the size of the first texture image file is used as default.
343 */
344void QTextureData::addImageData(const QTextureImageDataPtr &imageData)
345{
346 Q_D(QTextureData);
347 d->m_imagesData.push_back(t: imageData);
348}
349
350} // Qt3DRender
351
352QT_END_NAMESPACE
353

source code of qt3d/src/render/texture/qtexturedata.cpp