Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltexture.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | - | |||||||||||||
8 | - | |||||||||||||
9 | - | |||||||||||||
10 | QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarget, | - | ||||||||||||
11 | QOpenGLTexture *qq) | - | ||||||||||||
12 | : q_ptr(qq), | - | ||||||||||||
13 | context(0), | - | ||||||||||||
14 | target(textureTarget), | - | ||||||||||||
15 | textureId(0), | - | ||||||||||||
16 | format(QOpenGLTexture::NoFormat), | - | ||||||||||||
17 | formatClass(QOpenGLTexture::NoFormatClass), | - | ||||||||||||
18 | requestedMipLevels(1), | - | ||||||||||||
19 | mipLevels(-1), | - | ||||||||||||
20 | layers(1), | - | ||||||||||||
21 | faces(1), | - | ||||||||||||
22 | samples(0), | - | ||||||||||||
23 | fixedSamplePositions(true), | - | ||||||||||||
24 | baseLevel(0), | - | ||||||||||||
25 | maxLevel(1000), | - | ||||||||||||
26 | depthStencilMode(QOpenGLTexture::DepthMode), | - | ||||||||||||
27 | comparisonFunction(QOpenGLTexture::CompareLessEqual), | - | ||||||||||||
28 | comparisonMode(QOpenGLTexture::CompareNone), | - | ||||||||||||
29 | minFilter(QOpenGLTexture::Nearest), | - | ||||||||||||
30 | magFilter(QOpenGLTexture::Nearest), | - | ||||||||||||
31 | maxAnisotropy(1.0f), | - | ||||||||||||
32 | minLevelOfDetail(-1000.0f), | - | ||||||||||||
33 | maxLevelOfDetail(1000.0f), | - | ||||||||||||
34 | levelOfDetailBias(0.0f), | - | ||||||||||||
35 | textureView(false), | - | ||||||||||||
36 | autoGenerateMipMaps(true), | - | ||||||||||||
37 | storageAllocated(false), | - | ||||||||||||
38 | texFuncs(0), | - | ||||||||||||
39 | functions(0) | - | ||||||||||||
40 | { | - | ||||||||||||
41 | dimensions[0] = dimensions[1] = dimensions[2] = 1; | - | ||||||||||||
42 | - | |||||||||||||
43 | switch (target) { | - | ||||||||||||
44 | case never executed: QOpenGLTexture::Target1D:case QOpenGLTexture::Target1D: never executed: case QOpenGLTexture::Target1D: | 0 | ||||||||||||
45 | bindingTarget = QOpenGLTexture::BindingTarget1D; | - | ||||||||||||
46 | break; never executed: break; | 0 | ||||||||||||
47 | case never executed: QOpenGLTexture::Target1DArray:case QOpenGLTexture::Target1DArray: never executed: case QOpenGLTexture::Target1DArray: | 0 | ||||||||||||
48 | bindingTarget = QOpenGLTexture::BindingTarget1DArray; | - | ||||||||||||
49 | break; never executed: break; | 0 | ||||||||||||
50 | case never executed: QOpenGLTexture::Target2D:case QOpenGLTexture::Target2D: never executed: case QOpenGLTexture::Target2D: | 0 | ||||||||||||
51 | bindingTarget = QOpenGLTexture::BindingTarget2D; | - | ||||||||||||
52 | break; never executed: break; | 0 | ||||||||||||
53 | case never executed: QOpenGLTexture::Target2DArray:case QOpenGLTexture::Target2DArray: never executed: case QOpenGLTexture::Target2DArray: | 0 | ||||||||||||
54 | bindingTarget = QOpenGLTexture::BindingTarget2DArray; | - | ||||||||||||
55 | break; never executed: break; | 0 | ||||||||||||
56 | case never executed: QOpenGLTexture::Target3D:case QOpenGLTexture::Target3D: never executed: case QOpenGLTexture::Target3D: | 0 | ||||||||||||
57 | bindingTarget = QOpenGLTexture::BindingTarget3D; | - | ||||||||||||
58 | break; never executed: break; | 0 | ||||||||||||
59 | case never executed: QOpenGLTexture::TargetCubeMap:case QOpenGLTexture::TargetCubeMap: never executed: case QOpenGLTexture::TargetCubeMap: | 0 | ||||||||||||
60 | bindingTarget = QOpenGLTexture::BindingTargetCubeMap; | - | ||||||||||||
61 | faces = 6; | - | ||||||||||||
62 | break; never executed: break; | 0 | ||||||||||||
63 | case never executed: QOpenGLTexture::TargetCubeMapArray:case QOpenGLTexture::TargetCubeMapArray: never executed: case QOpenGLTexture::TargetCubeMapArray: | 0 | ||||||||||||
64 | bindingTarget = QOpenGLTexture::BindingTargetCubeMapArray; | - | ||||||||||||
65 | faces = 6; | - | ||||||||||||
66 | break; never executed: break; | 0 | ||||||||||||
67 | case never executed: QOpenGLTexture::Target2DMultisample:case QOpenGLTexture::Target2DMultisample: never executed: case QOpenGLTexture::Target2DMultisample: | 0 | ||||||||||||
68 | bindingTarget = QOpenGLTexture::BindingTarget2DMultisample; | - | ||||||||||||
69 | break; never executed: break; | 0 | ||||||||||||
70 | case never executed: QOpenGLTexture::Target2DMultisampleArray:case QOpenGLTexture::Target2DMultisampleArray: never executed: case QOpenGLTexture::Target2DMultisampleArray: | 0 | ||||||||||||
71 | bindingTarget = QOpenGLTexture::BindingTarget2DMultisampleArray; | - | ||||||||||||
72 | break; never executed: break; | 0 | ||||||||||||
73 | case never executed: QOpenGLTexture::TargetRectangle:case QOpenGLTexture::TargetRectangle: never executed: case QOpenGLTexture::TargetRectangle: | 0 | ||||||||||||
74 | bindingTarget = QOpenGLTexture::BindingTargetRectangle; | - | ||||||||||||
75 | break; never executed: break; | 0 | ||||||||||||
76 | case never executed: QOpenGLTexture::TargetBuffer:case QOpenGLTexture::TargetBuffer: never executed: case QOpenGLTexture::TargetBuffer: | 0 | ||||||||||||
77 | bindingTarget = QOpenGLTexture::BindingTargetBuffer; | - | ||||||||||||
78 | break; never executed: break; | 0 | ||||||||||||
79 | } | - | ||||||||||||
80 | - | |||||||||||||
81 | swizzleMask[0] = QOpenGLTexture::RedValue; | - | ||||||||||||
82 | swizzleMask[1] = QOpenGLTexture::GreenValue; | - | ||||||||||||
83 | swizzleMask[2] = QOpenGLTexture::BlueValue; | - | ||||||||||||
84 | swizzleMask[3] = QOpenGLTexture::AlphaValue; | - | ||||||||||||
85 | - | |||||||||||||
86 | wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle
| 0 | ||||||||||||
87 | ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; | - | ||||||||||||
88 | } never executed: end of block | 0 | ||||||||||||
89 | - | |||||||||||||
90 | QOpenGLTexturePrivate::~QOpenGLTexturePrivate() | - | ||||||||||||
91 | { | - | ||||||||||||
92 | destroy(); | - | ||||||||||||
93 | } | - | ||||||||||||
94 | - | |||||||||||||
95 | void QOpenGLTexturePrivate::initializeOpenGLFunctions() | - | ||||||||||||
96 | { | - | ||||||||||||
97 | - | |||||||||||||
98 | if (texFuncs) | - | ||||||||||||
99 | return; | - | ||||||||||||
100 | - | |||||||||||||
101 | - | |||||||||||||
102 | - | |||||||||||||
103 | - | |||||||||||||
104 | texFuncs = context->textureFunctions(); | - | ||||||||||||
105 | if (!texFuncs) { | - | ||||||||||||
106 | texFuncs = new QOpenGLTextureHelper(context); | - | ||||||||||||
107 | context->setTextureFunctions(texFuncs); | - | ||||||||||||
108 | } | - | ||||||||||||
109 | } | - | ||||||||||||
110 | - | |||||||||||||
111 | bool QOpenGLTexturePrivate::create() | - | ||||||||||||
112 | { | - | ||||||||||||
113 | if (textureId != 0
| 0 | ||||||||||||
114 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
115 | - | |||||||||||||
116 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
117 | if (!ctx
| 0 | ||||||||||||
118 | QMessageLogger(__FILE__, 157164, __PRETTY_FUNCTION__).warning("Requires a valid current OpenGL context.\n" | - | ||||||||||||
119 | "Texture has not been created"); | - | ||||||||||||
120 | return never executed: false;return false; never executed: return false; | 0 | ||||||||||||
121 | } | - | ||||||||||||
122 | context = ctx; | - | ||||||||||||
123 | functions = ctx->functions(); | - | ||||||||||||
124 | - | |||||||||||||
125 | - | |||||||||||||
126 | initializeOpenGLFunctions(); | - | ||||||||||||
127 | - | |||||||||||||
128 | - | |||||||||||||
129 | QOpenGLTexture::Feature feature = QOpenGLTexture::ImmutableStorage; | - | ||||||||||||
130 | while (feature != QOpenGLTexture::MaxFeatureFlag
| 0 | ||||||||||||
131 | if (QOpenGLTexture::hasFeature(feature)
| 0 | ||||||||||||
132 | features |= feature; never executed: features |= feature; | 0 | ||||||||||||
133 | feature = static_cast<QOpenGLTexture::Feature>(feature << 1); | - | ||||||||||||
134 | } never executed: end of block | 0 | ||||||||||||
135 | - | |||||||||||||
136 | texFuncsfunctions->glGenTextures(1, &textureId); | - | ||||||||||||
137 | return never executed: textureId != 0;return textureId != 0; never executed: return textureId != 0; | 0 | ||||||||||||
138 | } | - | ||||||||||||
139 | - | |||||||||||||
140 | void QOpenGLTexturePrivate::destroy() | - | ||||||||||||
141 | { | - | ||||||||||||
142 | if (!textureId
| 0 | ||||||||||||
143 | - | |||||||||||||
144 | return; never executed: return; | 0 | ||||||||||||
145 | } | - | ||||||||||||
146 | QOpenGLContext *currentContext = QOpenGLContext::currentContext(); | - | ||||||||||||
147 | if (!currentContext
| 0 | ||||||||||||
148 | QMessageLogger(__FILE__, 186194, __PRETTY_FUNCTION__).warning("Texture is not valid in the current context.\n" | - | ||||||||||||
149 | "Texture has not been destroyed"); | - | ||||||||||||
150 | return; never executed: return; | 0 | ||||||||||||
151 | } | - | ||||||||||||
152 | - | |||||||||||||
153 | texFuncsfunctions->glDeleteTextures(1, &textureId); | - | ||||||||||||
154 | - | |||||||||||||
155 | context = 0; | - | ||||||||||||
156 | functions = 0; | - | ||||||||||||
157 | textureId = 0; | - | ||||||||||||
158 | format = QOpenGLTexture::NoFormat; | - | ||||||||||||
159 | formatClass = QOpenGLTexture::NoFormatClass; | - | ||||||||||||
160 | requestedMipLevels = 1; | - | ||||||||||||
161 | mipLevels = -1; | - | ||||||||||||
162 | layers = 1; | - | ||||||||||||
163 | faces = 1; | - | ||||||||||||
164 | samples = 0; | - | ||||||||||||
165 | fixedSamplePositions = true, | - | ||||||||||||
166 | baseLevel = 0; | - | ||||||||||||
167 | maxLevel = 1000; | - | ||||||||||||
168 | depthStencilMode = QOpenGLTexture::DepthMode; | - | ||||||||||||
169 | minFilter = QOpenGLTexture::Nearest; | - | ||||||||||||
170 | magFilter = QOpenGLTexture::Nearest; | - | ||||||||||||
171 | maxAnisotropy = 1.0f; | - | ||||||||||||
172 | minLevelOfDetail = -1000.0f; | - | ||||||||||||
173 | maxLevelOfDetail = 1000.0f; | - | ||||||||||||
174 | levelOfDetailBias = 0.0f; | - | ||||||||||||
175 | textureView = false; | - | ||||||||||||
176 | autoGenerateMipMaps = true; | - | ||||||||||||
177 | storageAllocated = false; | - | ||||||||||||
178 | texFuncs = 0; | - | ||||||||||||
179 | - | |||||||||||||
180 | swizzleMask[0] = QOpenGLTexture::RedValue; | - | ||||||||||||
181 | swizzleMask[1] = QOpenGLTexture::GreenValue; | - | ||||||||||||
182 | swizzleMask[2] = QOpenGLTexture::BlueValue; | - | ||||||||||||
183 | swizzleMask[3] = QOpenGLTexture::AlphaValue; | - | ||||||||||||
184 | - | |||||||||||||
185 | wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle
| 0 | ||||||||||||
186 | ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; | - | ||||||||||||
187 | } never executed: end of block | 0 | ||||||||||||
188 | - | |||||||||||||
189 | void QOpenGLTexturePrivate::bind() | - | ||||||||||||
190 | { | - | ||||||||||||
191 | texFuncsfunctions->glBindTexture(target, textureId); | - | ||||||||||||
192 | } never executed: end of block | 0 | ||||||||||||
193 | - | |||||||||||||
194 | void QOpenGLTexturePrivate::bind(uint unit, QOpenGLTexture::TextureUnitReset reset) | - | ||||||||||||
195 | { | - | ||||||||||||
196 | GLint oldTextureUnit = 0; | - | ||||||||||||
197 | if (reset == QOpenGLTexture::ResetTextureUnit
| 0 | ||||||||||||
198 | texFuncsfunctions never executed: ->glGetIntegerv(0x84E0, &oldTextureUnit);functions->glGetIntegerv(0x84E0, &oldTextureUnit); never executed: functions->glGetIntegerv(0x84E0, &oldTextureUnit); | 0 | ||||||||||||
199 | - | |||||||||||||
200 | texFuncs->glActiveTexture(0x84C0 + unit); | - | ||||||||||||
201 | texFuncsfunctions->glBindTexture(target, textureId); | - | ||||||||||||
202 | - | |||||||||||||
203 | if (reset == QOpenGLTexture::ResetTextureUnit
| 0 | ||||||||||||
204 | texFuncs->glActiveTexture(0x84C0 + oldTextureUnit); never executed: texFuncs->glActiveTexture(0x84C0 + oldTextureUnit); | 0 | ||||||||||||
205 | } never executed: end of block | 0 | ||||||||||||
206 | - | |||||||||||||
207 | void QOpenGLTexturePrivate::release() | - | ||||||||||||
208 | { | - | ||||||||||||
209 | texFuncsfunctions->glBindTexture(target, 0); | - | ||||||||||||
210 | } never executed: end of block | 0 | ||||||||||||
211 | - | |||||||||||||
212 | void QOpenGLTexturePrivate::release(uint unit, QOpenGLTexture::TextureUnitReset reset) | - | ||||||||||||
213 | { | - | ||||||||||||
214 | GLint oldTextureUnit = 0; | - | ||||||||||||
215 | if (reset == QOpenGLTexture::ResetTextureUnit
| 0 | ||||||||||||
216 | texFuncsfunctions never executed: ->glGetIntegerv(0x84E0, &oldTextureUnit);functions->glGetIntegerv(0x84E0, &oldTextureUnit); never executed: functions->glGetIntegerv(0x84E0, &oldTextureUnit); | 0 | ||||||||||||
217 | - | |||||||||||||
218 | texFuncs->glActiveTexture(0x84C0 + unit); | - | ||||||||||||
219 | texFuncsfunctions->glBindTexture(target, 0); | - | ||||||||||||
220 | - | |||||||||||||
221 | if (reset == QOpenGLTexture::ResetTextureUnit
| 0 | ||||||||||||
222 | texFuncs->glActiveTexture(0x84C0 + oldTextureUnit); never executed: texFuncs->glActiveTexture(0x84C0 + oldTextureUnit); | 0 | ||||||||||||
223 | } never executed: end of block | 0 | ||||||||||||
224 | - | |||||||||||||
225 | bool QOpenGLTexturePrivate::isBound() const | - | ||||||||||||
226 | { | - | ||||||||||||
227 | GLint boundTextureId = 0; | - | ||||||||||||
228 | texFuncsfunctions->glGetIntegerv(bindingTarget, &boundTextureId); | - | ||||||||||||
229 | return never executed: (static_cast<GLuint>(boundTextureId) == textureId);return (static_cast<GLuint>(boundTextureId) == textureId); never executed: return (static_cast<GLuint>(boundTextureId) == textureId); | 0 | ||||||||||||
230 | } | - | ||||||||||||
231 | - | |||||||||||||
232 | bool QOpenGLTexturePrivate::isBound(uint unit) const | - | ||||||||||||
233 | { | - | ||||||||||||
234 | GLint oldTextureUnit = 0; | - | ||||||||||||
235 | texFuncsfunctions->glGetIntegerv(0x84E0, &oldTextureUnit); | - | ||||||||||||
236 | - | |||||||||||||
237 | GLint boundTextureId = 0; | - | ||||||||||||
238 | texFuncs->glActiveTexture(0x84C0 + unit); | - | ||||||||||||
239 | texFuncsfunctions->glGetIntegerv(bindingTarget, &boundTextureId); | - | ||||||||||||
240 | bool result = (static_cast<GLuint>(boundTextureId) == textureId); | - | ||||||||||||
241 | - | |||||||||||||
242 | texFuncs->glActiveTexture(0x84C0 + oldTextureUnit); | - | ||||||||||||
243 | return never executed: result;return result; never executed: return result; | 0 | ||||||||||||
244 | } | - | ||||||||||||
245 | - | |||||||||||||
246 | int QOpenGLTexturePrivate::evaluateMipLevels() const | - | ||||||||||||
247 | { | - | ||||||||||||
248 | switch (target) { | - | ||||||||||||
249 | case QOpenGLTexture::Target1D: | - | ||||||||||||
250 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
251 | case QOpenGLTexture::Target2D: | - | ||||||||||||
252 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
253 | case QOpenGLTexture::Target3D: | - | ||||||||||||
254 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
255 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
256 | return qMin(maximumMipLevelCount(), qMax(1, requestedMipLevels)); | - | ||||||||||||
257 | - | |||||||||||||
258 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
259 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
260 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
261 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
262 | default: | - | ||||||||||||
263 | return 1; | - | ||||||||||||
264 | } | - | ||||||||||||
265 | } | - | ||||||||||||
266 | - | |||||||||||||
267 | static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat) | - | ||||||||||||
268 | { | - | ||||||||||||
269 | switch (internalFormat) { | - | ||||||||||||
270 | case QOpenGLTexture::NoFormat: | - | ||||||||||||
271 | return false; | - | ||||||||||||
272 | - | |||||||||||||
273 | case QOpenGLTexture::R8_UNorm: | - | ||||||||||||
274 | case QOpenGLTexture::RG8_UNorm: | - | ||||||||||||
275 | case QOpenGLTexture::RGB8_UNorm: | - | ||||||||||||
276 | case QOpenGLTexture::RGBA8_UNorm: | - | ||||||||||||
277 | case QOpenGLTexture::R16_UNorm: | - | ||||||||||||
278 | case QOpenGLTexture::RG16_UNorm: | - | ||||||||||||
279 | case QOpenGLTexture::RGB16_UNorm: | - | ||||||||||||
280 | case QOpenGLTexture::RGBA16_UNorm: | - | ||||||||||||
281 | case QOpenGLTexture::R8_SNorm: | - | ||||||||||||
282 | case QOpenGLTexture::RG8_SNorm: | - | ||||||||||||
283 | case QOpenGLTexture::RGB8_SNorm: | - | ||||||||||||
284 | case QOpenGLTexture::RGBA8_SNorm: | - | ||||||||||||
285 | case QOpenGLTexture::R16_SNorm: | - | ||||||||||||
286 | case QOpenGLTexture::RG16_SNorm: | - | ||||||||||||
287 | case QOpenGLTexture::RGB16_SNorm: | - | ||||||||||||
288 | case QOpenGLTexture::RGBA16_SNorm: | - | ||||||||||||
289 | case QOpenGLTexture::R8U: | - | ||||||||||||
290 | case QOpenGLTexture::RG8U: | - | ||||||||||||
291 | case QOpenGLTexture::RGB8U: | - | ||||||||||||
292 | case QOpenGLTexture::RGBA8U: | - | ||||||||||||
293 | case QOpenGLTexture::R16U: | - | ||||||||||||
294 | case QOpenGLTexture::RG16U: | - | ||||||||||||
295 | case QOpenGLTexture::RGB16U: | - | ||||||||||||
296 | case QOpenGLTexture::RGBA16U: | - | ||||||||||||
297 | case QOpenGLTexture::R32U: | - | ||||||||||||
298 | case QOpenGLTexture::RG32U: | - | ||||||||||||
299 | case QOpenGLTexture::RGB32U: | - | ||||||||||||
300 | case QOpenGLTexture::RGBA32U: | - | ||||||||||||
301 | case QOpenGLTexture::R8I: | - | ||||||||||||
302 | case QOpenGLTexture::RG8I: | - | ||||||||||||
303 | case QOpenGLTexture::RGB8I: | - | ||||||||||||
304 | case QOpenGLTexture::RGBA8I: | - | ||||||||||||
305 | case QOpenGLTexture::R16I: | - | ||||||||||||
306 | case QOpenGLTexture::RG16I: | - | ||||||||||||
307 | case QOpenGLTexture::RGB16I: | - | ||||||||||||
308 | case QOpenGLTexture::RGBA16I: | - | ||||||||||||
309 | case QOpenGLTexture::R32I: | - | ||||||||||||
310 | case QOpenGLTexture::RG32I: | - | ||||||||||||
311 | case QOpenGLTexture::RGB32I: | - | ||||||||||||
312 | case QOpenGLTexture::RGBA32I: | - | ||||||||||||
313 | case QOpenGLTexture::R16F: | - | ||||||||||||
314 | case QOpenGLTexture::RG16F: | - | ||||||||||||
315 | case QOpenGLTexture::RGB16F: | - | ||||||||||||
316 | case QOpenGLTexture::RGBA16F: | - | ||||||||||||
317 | case QOpenGLTexture::R32F: | - | ||||||||||||
318 | case QOpenGLTexture::RG32F: | - | ||||||||||||
319 | case QOpenGLTexture::RGB32F: | - | ||||||||||||
320 | case QOpenGLTexture::RGBA32F: | - | ||||||||||||
321 | case QOpenGLTexture::RGB9E5: | - | ||||||||||||
322 | case QOpenGLTexture::RG11B10F: | - | ||||||||||||
323 | case QOpenGLTexture::RG3B2: | - | ||||||||||||
324 | case QOpenGLTexture::R5G6B5: | - | ||||||||||||
325 | case QOpenGLTexture::RGB5A1: | - | ||||||||||||
326 | case QOpenGLTexture::RGBA4: | - | ||||||||||||
327 | case QOpenGLTexture::RGB10A2: | - | ||||||||||||
328 | - | |||||||||||||
329 | case QOpenGLTexture::D16: | - | ||||||||||||
330 | case QOpenGLTexture::D24: | - | ||||||||||||
331 | case QOpenGLTexture::D32: | - | ||||||||||||
332 | case QOpenGLTexture::D32F: | - | ||||||||||||
333 | - | |||||||||||||
334 | case QOpenGLTexture::D24S8: | - | ||||||||||||
335 | case QOpenGLTexture::D32FS8X24: | - | ||||||||||||
336 | - | |||||||||||||
337 | case QOpenGLTexture::S8: | - | ||||||||||||
338 | - | |||||||||||||
339 | case QOpenGLTexture::RGB_DXT1: | - | ||||||||||||
340 | case QOpenGLTexture::RGBA_DXT1: | - | ||||||||||||
341 | case QOpenGLTexture::RGBA_DXT3: | - | ||||||||||||
342 | case QOpenGLTexture::RGBA_DXT5: | - | ||||||||||||
343 | case QOpenGLTexture::R_ATI1N_UNorm: | - | ||||||||||||
344 | case QOpenGLTexture::R_ATI1N_SNorm: | - | ||||||||||||
345 | case QOpenGLTexture::RG_ATI2N_UNorm: | - | ||||||||||||
346 | case QOpenGLTexture::RG_ATI2N_SNorm: | - | ||||||||||||
347 | case QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT: | - | ||||||||||||
348 | case QOpenGLTexture::RGB_BP_SIGNED_FLOAT: | - | ||||||||||||
349 | case QOpenGLTexture::RGB_BP_UNorm: | - | ||||||||||||
350 | case QOpenGLTexture::SRGB8: | - | ||||||||||||
351 | case QOpenGLTexture::SRGB8_Alpha8: | - | ||||||||||||
352 | case QOpenGLTexture::SRGB_DXT1: | - | ||||||||||||
353 | case QOpenGLTexture::SRGB_Alpha_DXT1: | - | ||||||||||||
354 | case QOpenGLTexture::SRGB_Alpha_DXT3: | - | ||||||||||||
355 | case QOpenGLTexture::SRGB_Alpha_DXT5: | - | ||||||||||||
356 | case QOpenGLTexture::SRGB_BP_UNorm: | - | ||||||||||||
357 | case QOpenGLTexture::R11_EAC_UNorm: | - | ||||||||||||
358 | case QOpenGLTexture::R11_EAC_SNorm: | - | ||||||||||||
359 | case QOpenGLTexture::RG11_EAC_UNorm: | - | ||||||||||||
360 | case QOpenGLTexture::RG11_EAC_SNorm: | - | ||||||||||||
361 | case QOpenGLTexture::RGB8_ETC2: | - | ||||||||||||
362 | case QOpenGLTexture::SRGB8_ETC2: | - | ||||||||||||
363 | case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
364 | case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
365 | case QOpenGLTexture::RGBA8_ETC2_EAC: | - | ||||||||||||
366 | case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: | - | ||||||||||||
367 | return true; | - | ||||||||||||
368 | - | |||||||||||||
369 | case QOpenGLTexture::RGB8_ETC1: | - | ||||||||||||
370 | return false; | - | ||||||||||||
371 | - | |||||||||||||
372 | case QOpenGLTexture::DepthFormat: | - | ||||||||||||
373 | case QOpenGLTexture::AlphaFormat: | - | ||||||||||||
374 | - | |||||||||||||
375 | case QOpenGLTexture::RGBFormat: | - | ||||||||||||
376 | case QOpenGLTexture::RGBAFormat: | - | ||||||||||||
377 | - | |||||||||||||
378 | case QOpenGLTexture::LuminanceFormat: | - | ||||||||||||
379 | - | |||||||||||||
380 | case QOpenGLTexture::LuminanceAlphaFormat: | - | ||||||||||||
381 | return false; | - | ||||||||||||
382 | } | - | ||||||||||||
383 | - | |||||||||||||
384 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,421430) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
385 | return false; | - | ||||||||||||
386 | } | - | ||||||||||||
387 | - | |||||||||||||
388 | static bool isTextureTargetMultisample(QOpenGLTexture::Target target) | - | ||||||||||||
389 | { | - | ||||||||||||
390 | switch (target) { | - | ||||||||||||
391 | case QOpenGLTexture::Target1D: | - | ||||||||||||
392 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
393 | case QOpenGLTexture::Target2D: | - | ||||||||||||
394 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
395 | case QOpenGLTexture::Target3D: | - | ||||||||||||
396 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
397 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
398 | return false; | - | ||||||||||||
399 | - | |||||||||||||
400 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
401 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
402 | return true; | - | ||||||||||||
403 | - | |||||||||||||
404 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
405 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
406 | return false; | - | ||||||||||||
407 | } | - | ||||||||||||
408 | - | |||||||||||||
409 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,446455) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
410 | return false; | - | ||||||||||||
411 | } | - | ||||||||||||
412 | - | |||||||||||||
413 | bool QOpenGLTexturePrivate::isUsingImmutableStorage() const | - | ||||||||||||
414 | { | - | ||||||||||||
415 | - | |||||||||||||
416 | - | |||||||||||||
417 | - | |||||||||||||
418 | return isSizedTextureFormat(format) | - | ||||||||||||
419 | && (isTextureTargetMultisample(target) | - | ||||||||||||
420 | ? features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage) | - | ||||||||||||
421 | : features.testFlag(QOpenGLTexture::ImmutableStorage)); | - | ||||||||||||
422 | } | - | ||||||||||||
423 | - | |||||||||||||
424 | void QOpenGLTexturePrivate::allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) | - | ||||||||||||
425 | { | - | ||||||||||||
426 | - | |||||||||||||
427 | mipLevels = evaluateMipLevels(); | - | ||||||||||||
428 | - | |||||||||||||
429 | if (isUsingImmutableStorage()) | - | ||||||||||||
430 | allocateImmutableStorage(); | - | ||||||||||||
431 | else | - | ||||||||||||
432 | allocateMutableStorage(pixelFormat, pixelType); | - | ||||||||||||
433 | } | - | ||||||||||||
434 | - | |||||||||||||
435 | static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat) | - | ||||||||||||
436 | { | - | ||||||||||||
437 | switch (internalFormat) { | - | ||||||||||||
438 | case QOpenGLTexture::NoFormat: | - | ||||||||||||
439 | return QOpenGLTexture::NoSourceFormat; | - | ||||||||||||
440 | - | |||||||||||||
441 | case QOpenGLTexture::R8_UNorm: | - | ||||||||||||
442 | return QOpenGLTexture::Red; | - | ||||||||||||
443 | - | |||||||||||||
444 | case QOpenGLTexture::RG8_UNorm: | - | ||||||||||||
445 | return QOpenGLTexture::RG; | - | ||||||||||||
446 | - | |||||||||||||
447 | case QOpenGLTexture::RGB8_UNorm: | - | ||||||||||||
448 | return QOpenGLTexture::RGB; | - | ||||||||||||
449 | - | |||||||||||||
450 | case QOpenGLTexture::RGBA8_UNorm: | - | ||||||||||||
451 | return QOpenGLTexture::RGBA; | - | ||||||||||||
452 | - | |||||||||||||
453 | case QOpenGLTexture::R16_UNorm: | - | ||||||||||||
454 | return QOpenGLTexture::Red; | - | ||||||||||||
455 | - | |||||||||||||
456 | case QOpenGLTexture::RG16_UNorm: | - | ||||||||||||
457 | return QOpenGLTexture::RG; | - | ||||||||||||
458 | - | |||||||||||||
459 | case QOpenGLTexture::RGB16_UNorm: | - | ||||||||||||
460 | return QOpenGLTexture::RGB; | - | ||||||||||||
461 | - | |||||||||||||
462 | case QOpenGLTexture::RGBA16_UNorm: | - | ||||||||||||
463 | return QOpenGLTexture::RGBA; | - | ||||||||||||
464 | - | |||||||||||||
465 | case QOpenGLTexture::R8_SNorm: | - | ||||||||||||
466 | return QOpenGLTexture::Red; | - | ||||||||||||
467 | - | |||||||||||||
468 | case QOpenGLTexture::RG8_SNorm: | - | ||||||||||||
469 | return QOpenGLTexture::RG; | - | ||||||||||||
470 | - | |||||||||||||
471 | case QOpenGLTexture::RGB8_SNorm: | - | ||||||||||||
472 | return QOpenGLTexture::RGB; | - | ||||||||||||
473 | - | |||||||||||||
474 | case QOpenGLTexture::RGBA8_SNorm: | - | ||||||||||||
475 | return QOpenGLTexture::RGBA; | - | ||||||||||||
476 | - | |||||||||||||
477 | case QOpenGLTexture::R16_SNorm: | - | ||||||||||||
478 | return QOpenGLTexture::Red; | - | ||||||||||||
479 | - | |||||||||||||
480 | case QOpenGLTexture::RG16_SNorm: | - | ||||||||||||
481 | return QOpenGLTexture::RG; | - | ||||||||||||
482 | - | |||||||||||||
483 | case QOpenGLTexture::RGB16_SNorm: | - | ||||||||||||
484 | return QOpenGLTexture::RGB; | - | ||||||||||||
485 | - | |||||||||||||
486 | case QOpenGLTexture::RGBA16_SNorm: | - | ||||||||||||
487 | return QOpenGLTexture::RGBA; | - | ||||||||||||
488 | - | |||||||||||||
489 | case QOpenGLTexture::R8U: | - | ||||||||||||
490 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
491 | - | |||||||||||||
492 | case QOpenGLTexture::RG8U: | - | ||||||||||||
493 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
494 | - | |||||||||||||
495 | case QOpenGLTexture::RGB8U: | - | ||||||||||||
496 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
497 | - | |||||||||||||
498 | case QOpenGLTexture::RGBA8U: | - | ||||||||||||
499 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
500 | - | |||||||||||||
501 | case QOpenGLTexture::R16U: | - | ||||||||||||
502 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
503 | - | |||||||||||||
504 | case QOpenGLTexture::RG16U: | - | ||||||||||||
505 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
506 | - | |||||||||||||
507 | case QOpenGLTexture::RGB16U: | - | ||||||||||||
508 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
509 | - | |||||||||||||
510 | case QOpenGLTexture::RGBA16U: | - | ||||||||||||
511 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
512 | - | |||||||||||||
513 | case QOpenGLTexture::R32U: | - | ||||||||||||
514 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
515 | - | |||||||||||||
516 | case QOpenGLTexture::RG32U: | - | ||||||||||||
517 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
518 | - | |||||||||||||
519 | case QOpenGLTexture::RGB32U: | - | ||||||||||||
520 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
521 | - | |||||||||||||
522 | case QOpenGLTexture::RGBA32U: | - | ||||||||||||
523 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
524 | - | |||||||||||||
525 | case QOpenGLTexture::R8I: | - | ||||||||||||
526 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
527 | - | |||||||||||||
528 | case QOpenGLTexture::RG8I: | - | ||||||||||||
529 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
530 | - | |||||||||||||
531 | case QOpenGLTexture::RGB8I: | - | ||||||||||||
532 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
533 | - | |||||||||||||
534 | case QOpenGLTexture::RGBA8I: | - | ||||||||||||
535 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
536 | - | |||||||||||||
537 | case QOpenGLTexture::R16I: | - | ||||||||||||
538 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
539 | - | |||||||||||||
540 | case QOpenGLTexture::RG16I: | - | ||||||||||||
541 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
542 | - | |||||||||||||
543 | case QOpenGLTexture::RGB16I: | - | ||||||||||||
544 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
545 | - | |||||||||||||
546 | case QOpenGLTexture::RGBA16I: | - | ||||||||||||
547 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
548 | - | |||||||||||||
549 | case QOpenGLTexture::R32I: | - | ||||||||||||
550 | return QOpenGLTexture::Red_Integer; | - | ||||||||||||
551 | - | |||||||||||||
552 | case QOpenGLTexture::RG32I: | - | ||||||||||||
553 | return QOpenGLTexture::RG_Integer; | - | ||||||||||||
554 | - | |||||||||||||
555 | case QOpenGLTexture::RGB32I: | - | ||||||||||||
556 | return QOpenGLTexture::RGB_Integer; | - | ||||||||||||
557 | - | |||||||||||||
558 | case QOpenGLTexture::RGBA32I: | - | ||||||||||||
559 | return QOpenGLTexture::RGBA_Integer; | - | ||||||||||||
560 | - | |||||||||||||
561 | case QOpenGLTexture::R16F: | - | ||||||||||||
562 | return QOpenGLTexture::Red; | - | ||||||||||||
563 | - | |||||||||||||
564 | case QOpenGLTexture::RG16F: | - | ||||||||||||
565 | return QOpenGLTexture::RG; | - | ||||||||||||
566 | - | |||||||||||||
567 | case QOpenGLTexture::RGB16F: | - | ||||||||||||
568 | return QOpenGLTexture::RGB; | - | ||||||||||||
569 | - | |||||||||||||
570 | case QOpenGLTexture::RGBA16F: | - | ||||||||||||
571 | return QOpenGLTexture::RGBA; | - | ||||||||||||
572 | - | |||||||||||||
573 | case QOpenGLTexture::R32F: | - | ||||||||||||
574 | return QOpenGLTexture::Red; | - | ||||||||||||
575 | - | |||||||||||||
576 | case QOpenGLTexture::RG32F: | - | ||||||||||||
577 | return QOpenGLTexture::RG; | - | ||||||||||||
578 | - | |||||||||||||
579 | case QOpenGLTexture::RGB32F: | - | ||||||||||||
580 | return QOpenGLTexture::RGB; | - | ||||||||||||
581 | - | |||||||||||||
582 | case QOpenGLTexture::RGBA32F: | - | ||||||||||||
583 | return QOpenGLTexture::RGBA; | - | ||||||||||||
584 | - | |||||||||||||
585 | case QOpenGLTexture::RGB9E5: | - | ||||||||||||
586 | return QOpenGLTexture::RGB; | - | ||||||||||||
587 | - | |||||||||||||
588 | case QOpenGLTexture::RG11B10F: | - | ||||||||||||
589 | return QOpenGLTexture::RGB; | - | ||||||||||||
590 | - | |||||||||||||
591 | case QOpenGLTexture::RG3B2: | - | ||||||||||||
592 | return QOpenGLTexture::RGB; | - | ||||||||||||
593 | - | |||||||||||||
594 | case QOpenGLTexture::R5G6B5: | - | ||||||||||||
595 | return QOpenGLTexture::RGB; | - | ||||||||||||
596 | - | |||||||||||||
597 | case QOpenGLTexture::RGB5A1: | - | ||||||||||||
598 | return QOpenGLTexture::RGBA; | - | ||||||||||||
599 | - | |||||||||||||
600 | case QOpenGLTexture::RGBA4: | - | ||||||||||||
601 | return QOpenGLTexture::RGBA; | - | ||||||||||||
602 | - | |||||||||||||
603 | case QOpenGLTexture::RGB10A2: | - | ||||||||||||
604 | return QOpenGLTexture::RGBA; | - | ||||||||||||
605 | - | |||||||||||||
606 | case QOpenGLTexture::D16: | - | ||||||||||||
607 | case QOpenGLTexture::D24: | - | ||||||||||||
608 | case QOpenGLTexture::D32: | - | ||||||||||||
609 | case QOpenGLTexture::D32F: | - | ||||||||||||
610 | return QOpenGLTexture::Depth; | - | ||||||||||||
611 | - | |||||||||||||
612 | case QOpenGLTexture::D24S8: | - | ||||||||||||
613 | case QOpenGLTexture::D32FS8X24: | - | ||||||||||||
614 | return QOpenGLTexture::DepthStencil; | - | ||||||||||||
615 | - | |||||||||||||
616 | case QOpenGLTexture::S8: | - | ||||||||||||
617 | return QOpenGLTexture::Stencil; | - | ||||||||||||
618 | - | |||||||||||||
619 | case QOpenGLTexture::RGB_DXT1: | - | ||||||||||||
620 | case QOpenGLTexture::RGBA_DXT1: | - | ||||||||||||
621 | case QOpenGLTexture::RGBA_DXT3: | - | ||||||||||||
622 | case QOpenGLTexture::RGBA_DXT5: | - | ||||||||||||
623 | case QOpenGLTexture::R_ATI1N_UNorm: | - | ||||||||||||
624 | case QOpenGLTexture::R_ATI1N_SNorm: | - | ||||||||||||
625 | case QOpenGLTexture::RG_ATI2N_UNorm: | - | ||||||||||||
626 | case QOpenGLTexture::RG_ATI2N_SNorm: | - | ||||||||||||
627 | case QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT: | - | ||||||||||||
628 | case QOpenGLTexture::RGB_BP_SIGNED_FLOAT: | - | ||||||||||||
629 | case QOpenGLTexture::RGB_BP_UNorm: | - | ||||||||||||
630 | case QOpenGLTexture::SRGB8: | - | ||||||||||||
631 | case QOpenGLTexture::SRGB8_Alpha8: | - | ||||||||||||
632 | case QOpenGLTexture::SRGB_DXT1: | - | ||||||||||||
633 | case QOpenGLTexture::SRGB_Alpha_DXT1: | - | ||||||||||||
634 | case QOpenGLTexture::SRGB_Alpha_DXT3: | - | ||||||||||||
635 | case QOpenGLTexture::SRGB_Alpha_DXT5: | - | ||||||||||||
636 | case QOpenGLTexture::SRGB_BP_UNorm: | - | ||||||||||||
637 | case QOpenGLTexture::RGB8_ETC1: | - | ||||||||||||
638 | return QOpenGLTexture::RGBA; | - | ||||||||||||
639 | - | |||||||||||||
640 | case QOpenGLTexture::R11_EAC_UNorm: | - | ||||||||||||
641 | case QOpenGLTexture::R11_EAC_SNorm: | - | ||||||||||||
642 | return QOpenGLTexture::Red; | - | ||||||||||||
643 | - | |||||||||||||
644 | case QOpenGLTexture::RG11_EAC_UNorm: | - | ||||||||||||
645 | case QOpenGLTexture::RG11_EAC_SNorm: | - | ||||||||||||
646 | return QOpenGLTexture::RG; | - | ||||||||||||
647 | - | |||||||||||||
648 | case QOpenGLTexture::RGB8_ETC2: | - | ||||||||||||
649 | case QOpenGLTexture::SRGB8_ETC2: | - | ||||||||||||
650 | return QOpenGLTexture::RGB; | - | ||||||||||||
651 | - | |||||||||||||
652 | case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
653 | case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
654 | return QOpenGLTexture::RGBA; | - | ||||||||||||
655 | - | |||||||||||||
656 | case QOpenGLTexture::RGBA8_ETC2_EAC: | - | ||||||||||||
657 | case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: | - | ||||||||||||
658 | return QOpenGLTexture::RGBA; | - | ||||||||||||
659 | - | |||||||||||||
660 | case QOpenGLTexture::DepthFormat: | - | ||||||||||||
661 | return QOpenGLTexture::Depth; | - | ||||||||||||
662 | - | |||||||||||||
663 | case QOpenGLTexture::AlphaFormat: | - | ||||||||||||
664 | return QOpenGLTexture::Alpha; | - | ||||||||||||
665 | - | |||||||||||||
666 | case QOpenGLTexture::RGBFormat: | - | ||||||||||||
667 | case QOpenGLTexture::RGBAFormat: | - | ||||||||||||
668 | return QOpenGLTexture::RGBA; | - | ||||||||||||
669 | - | |||||||||||||
670 | case QOpenGLTexture::LuminanceFormat: | - | ||||||||||||
671 | return QOpenGLTexture::Luminance; | - | ||||||||||||
672 | - | |||||||||||||
673 | case QOpenGLTexture::LuminanceAlphaFormat: | - | ||||||||||||
674 | return QOpenGLTexture::LuminanceAlpha; | - | ||||||||||||
675 | } | - | ||||||||||||
676 | - | |||||||||||||
677 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,714723) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
678 | return QOpenGLTexture::NoSourceFormat; | - | ||||||||||||
679 | } | - | ||||||||||||
680 | - | |||||||||||||
681 | static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat) | - | ||||||||||||
682 | { | - | ||||||||||||
683 | switch (internalFormat) { | - | ||||||||||||
684 | case QOpenGLTexture::NoFormat: | - | ||||||||||||
685 | return QOpenGLTexture::NoPixelType; | - | ||||||||||||
686 | - | |||||||||||||
687 | case QOpenGLTexture::R8_UNorm: | - | ||||||||||||
688 | case QOpenGLTexture::RG8_UNorm: | - | ||||||||||||
689 | case QOpenGLTexture::RGB8_UNorm: | - | ||||||||||||
690 | case QOpenGLTexture::RGBA8_UNorm: | - | ||||||||||||
691 | case QOpenGLTexture::R16_UNorm: | - | ||||||||||||
692 | case QOpenGLTexture::RG16_UNorm: | - | ||||||||||||
693 | case QOpenGLTexture::RGB16_UNorm: | - | ||||||||||||
694 | case QOpenGLTexture::RGBA16_UNorm: | - | ||||||||||||
695 | return QOpenGLTexture::UInt8; | - | ||||||||||||
696 | - | |||||||||||||
697 | case QOpenGLTexture::R8_SNorm: | - | ||||||||||||
698 | case QOpenGLTexture::RG8_SNorm: | - | ||||||||||||
699 | case QOpenGLTexture::RGB8_SNorm: | - | ||||||||||||
700 | case QOpenGLTexture::RGBA8_SNorm: | - | ||||||||||||
701 | case QOpenGLTexture::R16_SNorm: | - | ||||||||||||
702 | case QOpenGLTexture::RG16_SNorm: | - | ||||||||||||
703 | case QOpenGLTexture::RGB16_SNorm: | - | ||||||||||||
704 | case QOpenGLTexture::RGBA16_SNorm: | - | ||||||||||||
705 | return QOpenGLTexture::Int8; | - | ||||||||||||
706 | - | |||||||||||||
707 | case QOpenGLTexture::R8U: | - | ||||||||||||
708 | case QOpenGLTexture::RG8U: | - | ||||||||||||
709 | case QOpenGLTexture::RGB8U: | - | ||||||||||||
710 | case QOpenGLTexture::RGBA8U: | - | ||||||||||||
711 | case QOpenGLTexture::R16U: | - | ||||||||||||
712 | case QOpenGLTexture::RG16U: | - | ||||||||||||
713 | case QOpenGLTexture::RGB16U: | - | ||||||||||||
714 | case QOpenGLTexture::RGBA16U: | - | ||||||||||||
715 | case QOpenGLTexture::R32U: | - | ||||||||||||
716 | case QOpenGLTexture::RG32U: | - | ||||||||||||
717 | case QOpenGLTexture::RGB32U: | - | ||||||||||||
718 | case QOpenGLTexture::RGBA32U: | - | ||||||||||||
719 | return QOpenGLTexture::UInt8; | - | ||||||||||||
720 | - | |||||||||||||
721 | case QOpenGLTexture::R8I: | - | ||||||||||||
722 | case QOpenGLTexture::RG8I: | - | ||||||||||||
723 | case QOpenGLTexture::RGB8I: | - | ||||||||||||
724 | case QOpenGLTexture::RGBA8I: | - | ||||||||||||
725 | case QOpenGLTexture::R16I: | - | ||||||||||||
726 | case QOpenGLTexture::RG16I: | - | ||||||||||||
727 | case QOpenGLTexture::RGB16I: | - | ||||||||||||
728 | case QOpenGLTexture::RGBA16I: | - | ||||||||||||
729 | case QOpenGLTexture::R32I: | - | ||||||||||||
730 | case QOpenGLTexture::RG32I: | - | ||||||||||||
731 | case QOpenGLTexture::RGB32I: | - | ||||||||||||
732 | case QOpenGLTexture::RGBA32I: | - | ||||||||||||
733 | return QOpenGLTexture::Int8; | - | ||||||||||||
734 | - | |||||||||||||
735 | case QOpenGLTexture::R16F: | - | ||||||||||||
736 | case QOpenGLTexture::RG16F: | - | ||||||||||||
737 | case QOpenGLTexture::RGB16F: | - | ||||||||||||
738 | case QOpenGLTexture::RGBA16F: | - | ||||||||||||
739 | return QOpenGLTexture::Float16; | - | ||||||||||||
740 | - | |||||||||||||
741 | case QOpenGLTexture::R32F: | - | ||||||||||||
742 | case QOpenGLTexture::RG32F: | - | ||||||||||||
743 | case QOpenGLTexture::RGB32F: | - | ||||||||||||
744 | case QOpenGLTexture::RGBA32F: | - | ||||||||||||
745 | return QOpenGLTexture::Float32; | - | ||||||||||||
746 | - | |||||||||||||
747 | case QOpenGLTexture::RGB9E5: | - | ||||||||||||
748 | return QOpenGLTexture::UInt16_RGB5A1_Rev; | - | ||||||||||||
749 | - | |||||||||||||
750 | case QOpenGLTexture::RG11B10F: | - | ||||||||||||
751 | return QOpenGLTexture::UInt32_RG11B10F; | - | ||||||||||||
752 | - | |||||||||||||
753 | case QOpenGLTexture::RG3B2: | - | ||||||||||||
754 | return QOpenGLTexture::UInt8_RG3B2; | - | ||||||||||||
755 | - | |||||||||||||
756 | case QOpenGLTexture::R5G6B5: | - | ||||||||||||
757 | return QOpenGLTexture::UInt16_R5G6B5; | - | ||||||||||||
758 | - | |||||||||||||
759 | case QOpenGLTexture::RGB5A1: | - | ||||||||||||
760 | return QOpenGLTexture::UInt16_RGB5A1; | - | ||||||||||||
761 | - | |||||||||||||
762 | case QOpenGLTexture::RGBA4: | - | ||||||||||||
763 | return QOpenGLTexture::UInt16_RGBA4; | - | ||||||||||||
764 | - | |||||||||||||
765 | case QOpenGLTexture::RGB10A2: | - | ||||||||||||
766 | return QOpenGLTexture::UInt32_RGB10A2; | - | ||||||||||||
767 | - | |||||||||||||
768 | case QOpenGLTexture::D16: | - | ||||||||||||
769 | return QOpenGLTexture::UInt16; | - | ||||||||||||
770 | - | |||||||||||||
771 | case QOpenGLTexture::D24: | - | ||||||||||||
772 | case QOpenGLTexture::D32: | - | ||||||||||||
773 | return QOpenGLTexture::UInt32; | - | ||||||||||||
774 | - | |||||||||||||
775 | case QOpenGLTexture::D32F: | - | ||||||||||||
776 | return QOpenGLTexture::Float32; | - | ||||||||||||
777 | - | |||||||||||||
778 | case QOpenGLTexture::D24S8: | - | ||||||||||||
779 | return QOpenGLTexture::UInt32_D24S8; | - | ||||||||||||
780 | - | |||||||||||||
781 | case QOpenGLTexture::D32FS8X24: | - | ||||||||||||
782 | return QOpenGLTexture::Float32_D32_UInt32_S8_X24; | - | ||||||||||||
783 | - | |||||||||||||
784 | case QOpenGLTexture::S8: | - | ||||||||||||
785 | return QOpenGLTexture::UInt8; | - | ||||||||||||
786 | - | |||||||||||||
787 | case QOpenGLTexture::RGB_DXT1: | - | ||||||||||||
788 | case QOpenGLTexture::RGBA_DXT1: | - | ||||||||||||
789 | case QOpenGLTexture::RGBA_DXT3: | - | ||||||||||||
790 | case QOpenGLTexture::RGBA_DXT5: | - | ||||||||||||
791 | case QOpenGLTexture::R_ATI1N_UNorm: | - | ||||||||||||
792 | case QOpenGLTexture::R_ATI1N_SNorm: | - | ||||||||||||
793 | case QOpenGLTexture::RG_ATI2N_UNorm: | - | ||||||||||||
794 | case QOpenGLTexture::RG_ATI2N_SNorm: | - | ||||||||||||
795 | case QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT: | - | ||||||||||||
796 | case QOpenGLTexture::RGB_BP_SIGNED_FLOAT: | - | ||||||||||||
797 | case QOpenGLTexture::RGB_BP_UNorm: | - | ||||||||||||
798 | case QOpenGLTexture::SRGB8: | - | ||||||||||||
799 | case QOpenGLTexture::SRGB8_Alpha8: | - | ||||||||||||
800 | case QOpenGLTexture::SRGB_DXT1: | - | ||||||||||||
801 | case QOpenGLTexture::SRGB_Alpha_DXT1: | - | ||||||||||||
802 | case QOpenGLTexture::SRGB_Alpha_DXT3: | - | ||||||||||||
803 | case QOpenGLTexture::SRGB_Alpha_DXT5: | - | ||||||||||||
804 | case QOpenGLTexture::SRGB_BP_UNorm: | - | ||||||||||||
805 | case QOpenGLTexture::R11_EAC_UNorm: | - | ||||||||||||
806 | case QOpenGLTexture::R11_EAC_SNorm: | - | ||||||||||||
807 | case QOpenGLTexture::RG11_EAC_UNorm: | - | ||||||||||||
808 | case QOpenGLTexture::RG11_EAC_SNorm: | - | ||||||||||||
809 | case QOpenGLTexture::RGB8_ETC2: | - | ||||||||||||
810 | case QOpenGLTexture::SRGB8_ETC2: | - | ||||||||||||
811 | case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
812 | case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
813 | case QOpenGLTexture::RGBA8_ETC2_EAC: | - | ||||||||||||
814 | case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: | - | ||||||||||||
815 | case QOpenGLTexture::RGB8_ETC1: | - | ||||||||||||
816 | return QOpenGLTexture::UInt8; | - | ||||||||||||
817 | - | |||||||||||||
818 | case QOpenGLTexture::DepthFormat: | - | ||||||||||||
819 | return QOpenGLTexture::UInt32; | - | ||||||||||||
820 | - | |||||||||||||
821 | case QOpenGLTexture::AlphaFormat: | - | ||||||||||||
822 | case QOpenGLTexture::RGBFormat: | - | ||||||||||||
823 | case QOpenGLTexture::RGBAFormat: | - | ||||||||||||
824 | case QOpenGLTexture::LuminanceFormat: | - | ||||||||||||
825 | case QOpenGLTexture::LuminanceAlphaFormat: | - | ||||||||||||
826 | return QOpenGLTexture::UInt8; | - | ||||||||||||
827 | } | - | ||||||||||||
828 | - | |||||||||||||
829 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,866875) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
830 | return QOpenGLTexture::NoPixelType; | - | ||||||||||||
831 | } | - | ||||||||||||
832 | - | |||||||||||||
833 | static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) | - | ||||||||||||
834 | { | - | ||||||||||||
835 | switch (internalFormat) { | - | ||||||||||||
836 | case QOpenGLTexture::NoFormat: | - | ||||||||||||
837 | - | |||||||||||||
838 | case QOpenGLTexture::R8_UNorm: | - | ||||||||||||
839 | case QOpenGLTexture::RG8_UNorm: | - | ||||||||||||
840 | case QOpenGLTexture::RGB8_UNorm: | - | ||||||||||||
841 | case QOpenGLTexture::RGBA8_UNorm: | - | ||||||||||||
842 | case QOpenGLTexture::R16_UNorm: | - | ||||||||||||
843 | case QOpenGLTexture::RG16_UNorm: | - | ||||||||||||
844 | case QOpenGLTexture::RGB16_UNorm: | - | ||||||||||||
845 | case QOpenGLTexture::RGBA16_UNorm: | - | ||||||||||||
846 | case QOpenGLTexture::R8_SNorm: | - | ||||||||||||
847 | case QOpenGLTexture::RG8_SNorm: | - | ||||||||||||
848 | case QOpenGLTexture::RGB8_SNorm: | - | ||||||||||||
849 | case QOpenGLTexture::RGBA8_SNorm: | - | ||||||||||||
850 | case QOpenGLTexture::R16_SNorm: | - | ||||||||||||
851 | case QOpenGLTexture::RG16_SNorm: | - | ||||||||||||
852 | case QOpenGLTexture::RGB16_SNorm: | - | ||||||||||||
853 | case QOpenGLTexture::RGBA16_SNorm: | - | ||||||||||||
854 | case QOpenGLTexture::R8U: | - | ||||||||||||
855 | case QOpenGLTexture::RG8U: | - | ||||||||||||
856 | case QOpenGLTexture::RGB8U: | - | ||||||||||||
857 | case QOpenGLTexture::RGBA8U: | - | ||||||||||||
858 | case QOpenGLTexture::R16U: | - | ||||||||||||
859 | case QOpenGLTexture::RG16U: | - | ||||||||||||
860 | case QOpenGLTexture::RGB16U: | - | ||||||||||||
861 | case QOpenGLTexture::RGBA16U: | - | ||||||||||||
862 | case QOpenGLTexture::R32U: | - | ||||||||||||
863 | case QOpenGLTexture::RG32U: | - | ||||||||||||
864 | case QOpenGLTexture::RGB32U: | - | ||||||||||||
865 | case QOpenGLTexture::RGBA32U: | - | ||||||||||||
866 | case QOpenGLTexture::R8I: | - | ||||||||||||
867 | case QOpenGLTexture::RG8I: | - | ||||||||||||
868 | case QOpenGLTexture::RGB8I: | - | ||||||||||||
869 | case QOpenGLTexture::RGBA8I: | - | ||||||||||||
870 | case QOpenGLTexture::R16I: | - | ||||||||||||
871 | case QOpenGLTexture::RG16I: | - | ||||||||||||
872 | case QOpenGLTexture::RGB16I: | - | ||||||||||||
873 | case QOpenGLTexture::RGBA16I: | - | ||||||||||||
874 | case QOpenGLTexture::R32I: | - | ||||||||||||
875 | case QOpenGLTexture::RG32I: | - | ||||||||||||
876 | case QOpenGLTexture::RGB32I: | - | ||||||||||||
877 | case QOpenGLTexture::RGBA32I: | - | ||||||||||||
878 | case QOpenGLTexture::R16F: | - | ||||||||||||
879 | case QOpenGLTexture::RG16F: | - | ||||||||||||
880 | case QOpenGLTexture::RGB16F: | - | ||||||||||||
881 | case QOpenGLTexture::RGBA16F: | - | ||||||||||||
882 | case QOpenGLTexture::R32F: | - | ||||||||||||
883 | case QOpenGLTexture::RG32F: | - | ||||||||||||
884 | case QOpenGLTexture::RGB32F: | - | ||||||||||||
885 | case QOpenGLTexture::RGBA32F: | - | ||||||||||||
886 | case QOpenGLTexture::RGB9E5: | - | ||||||||||||
887 | case QOpenGLTexture::RG11B10F: | - | ||||||||||||
888 | case QOpenGLTexture::RG3B2: | - | ||||||||||||
889 | case QOpenGLTexture::R5G6B5: | - | ||||||||||||
890 | case QOpenGLTexture::RGB5A1: | - | ||||||||||||
891 | case QOpenGLTexture::RGBA4: | - | ||||||||||||
892 | case QOpenGLTexture::RGB10A2: | - | ||||||||||||
893 | - | |||||||||||||
894 | case QOpenGLTexture::D16: | - | ||||||||||||
895 | case QOpenGLTexture::D24: | - | ||||||||||||
896 | case QOpenGLTexture::D32: | - | ||||||||||||
897 | case QOpenGLTexture::D32F: | - | ||||||||||||
898 | - | |||||||||||||
899 | case QOpenGLTexture::D24S8: | - | ||||||||||||
900 | case QOpenGLTexture::D32FS8X24: | - | ||||||||||||
901 | - | |||||||||||||
902 | case QOpenGLTexture::S8: | - | ||||||||||||
903 | return false; | - | ||||||||||||
904 | - | |||||||||||||
905 | case QOpenGLTexture::RGB_DXT1: | - | ||||||||||||
906 | case QOpenGLTexture::RGBA_DXT1: | - | ||||||||||||
907 | case QOpenGLTexture::RGBA_DXT3: | - | ||||||||||||
908 | case QOpenGLTexture::RGBA_DXT5: | - | ||||||||||||
909 | case QOpenGLTexture::R_ATI1N_UNorm: | - | ||||||||||||
910 | case QOpenGLTexture::R_ATI1N_SNorm: | - | ||||||||||||
911 | case QOpenGLTexture::RG_ATI2N_UNorm: | - | ||||||||||||
912 | case QOpenGLTexture::RG_ATI2N_SNorm: | - | ||||||||||||
913 | case QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT: | - | ||||||||||||
914 | case QOpenGLTexture::RGB_BP_SIGNED_FLOAT: | - | ||||||||||||
915 | case QOpenGLTexture::RGB_BP_UNorm: | - | ||||||||||||
916 | case QOpenGLTexture::SRGB8: | - | ||||||||||||
917 | case QOpenGLTexture::SRGB8_Alpha8: | - | ||||||||||||
918 | case QOpenGLTexture::SRGB_DXT1: | - | ||||||||||||
919 | case QOpenGLTexture::SRGB_Alpha_DXT1: | - | ||||||||||||
920 | case QOpenGLTexture::SRGB_Alpha_DXT3: | - | ||||||||||||
921 | case QOpenGLTexture::SRGB_Alpha_DXT5: | - | ||||||||||||
922 | case QOpenGLTexture::SRGB_BP_UNorm: | - | ||||||||||||
923 | case QOpenGLTexture::R11_EAC_UNorm: | - | ||||||||||||
924 | case QOpenGLTexture::R11_EAC_SNorm: | - | ||||||||||||
925 | case QOpenGLTexture::RG11_EAC_UNorm: | - | ||||||||||||
926 | case QOpenGLTexture::RG11_EAC_SNorm: | - | ||||||||||||
927 | case QOpenGLTexture::RGB8_ETC2: | - | ||||||||||||
928 | case QOpenGLTexture::SRGB8_ETC2: | - | ||||||||||||
929 | case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
930 | case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
931 | case QOpenGLTexture::RGBA8_ETC2_EAC: | - | ||||||||||||
932 | case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: | - | ||||||||||||
933 | case QOpenGLTexture::RGB8_ETC1: | - | ||||||||||||
934 | return true; | - | ||||||||||||
935 | - | |||||||||||||
936 | case QOpenGLTexture::DepthFormat: | - | ||||||||||||
937 | case QOpenGLTexture::AlphaFormat: | - | ||||||||||||
938 | case QOpenGLTexture::RGBFormat: | - | ||||||||||||
939 | case QOpenGLTexture::RGBAFormat: | - | ||||||||||||
940 | case QOpenGLTexture::LuminanceFormat: | - | ||||||||||||
941 | case QOpenGLTexture::LuminanceAlphaFormat: | - | ||||||||||||
942 | return false; | - | ||||||||||||
943 | } | - | ||||||||||||
944 | - | |||||||||||||
945 | do { ((!(false)) ? qt_assert_x("Q_UNREACHABLE()", "Q_UNREACHABLE was reached",__FILE__,982991) : qt_noop()); __builtin_unreachable(); } while (0); | - | ||||||||||||
946 | return false; | - | ||||||||||||
947 | } | - | ||||||||||||
948 | - | |||||||||||||
949 | void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) | - | ||||||||||||
950 | { | - | ||||||||||||
951 | - | |||||||||||||
952 | - | |||||||||||||
953 | - | |||||||||||||
954 | - | |||||||||||||
955 | if (isCompressedFormat(format)) { | - | ||||||||||||
956 | storageAllocated = true; | - | ||||||||||||
957 | return; | - | ||||||||||||
958 | } | - | ||||||||||||
959 | - | |||||||||||||
960 | switch (target) { | - | ||||||||||||
961 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
962 | - | |||||||||||||
963 | QMessageLogger(__FILE__, 10001009, __PRETTY_FUNCTION__).warning("Buffer textures do not allocate storage"); | - | ||||||||||||
964 | return; | - | ||||||||||||
965 | - | |||||||||||||
966 | case QOpenGLTexture::Target1D: | - | ||||||||||||
967 | if (features.testFlag(QOpenGLTexture::Texture1D)) { | - | ||||||||||||
968 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
969 | texFuncs->glTextureImage1D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
970 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
971 | 0, | - | ||||||||||||
972 | pixelFormat, pixelType, 0); | - | ||||||||||||
973 | } else { | - | ||||||||||||
974 | QMessageLogger(__FILE__, 10111020, __PRETTY_FUNCTION__).warning("1D textures are not supported"); | - | ||||||||||||
975 | return; | - | ||||||||||||
976 | } | - | ||||||||||||
977 | break; | - | ||||||||||||
978 | - | |||||||||||||
979 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
980 | if (features.testFlag(QOpenGLTexture::Texture1D) | - | ||||||||||||
981 | && features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
982 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
983 | texFuncs->glTextureImage2D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
984 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
985 | layers, | - | ||||||||||||
986 | 0, | - | ||||||||||||
987 | pixelFormat, pixelType, 0); | - | ||||||||||||
988 | } else { | - | ||||||||||||
989 | QMessageLogger(__FILE__, 10261035, __PRETTY_FUNCTION__).warning("1D array textures are not supported"); | - | ||||||||||||
990 | return; | - | ||||||||||||
991 | } | - | ||||||||||||
992 | break; | - | ||||||||||||
993 | - | |||||||||||||
994 | case QOpenGLTexture::Target2D: | - | ||||||||||||
995 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
996 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
997 | texFuncs->glTextureImage2D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
998 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
999 | mipLevelSize(level, dimensions[1]), | - | ||||||||||||
1000 | 0, | - | ||||||||||||
1001 | pixelFormat, pixelType, 0); | - | ||||||||||||
1002 | break; | - | ||||||||||||
1003 | - | |||||||||||||
1004 | case QOpenGLTexture::TargetCubeMap: { | - | ||||||||||||
1005 | - | |||||||||||||
1006 | - | |||||||||||||
1007 | - | |||||||||||||
1008 | const QOpenGLTexture::CubeMapFace faceTargets[] = { | - | ||||||||||||
1009 | QOpenGLTexture::CubeMapPositiveX, QOpenGLTexture::CubeMapNegativeX, | - | ||||||||||||
1010 | QOpenGLTexture::CubeMapPositiveY, QOpenGLTexture::CubeMapNegativeY, | - | ||||||||||||
1011 | QOpenGLTexture::CubeMapPositiveZ, QOpenGLTexture::CubeMapNegativeZ | - | ||||||||||||
1012 | }; | - | ||||||||||||
1013 | - | |||||||||||||
1014 | for (int faceTarget = 0; faceTarget < 6; ++faceTarget) { | - | ||||||||||||
1015 | for (int level = 0; level < mipLevels; ++level) { | - | ||||||||||||
1016 | texFuncs->glTextureImage2D(textureId, faceTargets[faceTarget], bindingTarget, | - | ||||||||||||
1017 | level, format, | - | ||||||||||||
1018 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
1019 | mipLevelSize(level, dimensions[1]), | - | ||||||||||||
1020 | 0, | - | ||||||||||||
1021 | pixelFormat, pixelType, 0); | - | ||||||||||||
1022 | } | - | ||||||||||||
1023 | } | - | ||||||||||||
1024 | break; | - | ||||||||||||
1025 | } | - | ||||||||||||
1026 | - | |||||||||||||
1027 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1028 | if (features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
1029 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
1030 | texFuncs->glTextureImage3D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
1031 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
1032 | mipLevelSize(level, dimensions[1]), | - | ||||||||||||
1033 | layers, | - | ||||||||||||
1034 | 0, | - | ||||||||||||
1035 | pixelFormat, pixelType, 0); | - | ||||||||||||
1036 | } else { | - | ||||||||||||
1037 | QMessageLogger(__FILE__, 10741083, __PRETTY_FUNCTION__).warning("Array textures are not supported"); | - | ||||||||||||
1038 | return; | - | ||||||||||||
1039 | } | - | ||||||||||||
1040 | break; | - | ||||||||||||
1041 | - | |||||||||||||
1042 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1043 | - | |||||||||||||
1044 | if (features.testFlag(QOpenGLTexture::TextureCubeMapArrays)) { | - | ||||||||||||
1045 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
1046 | texFuncs->glTextureImage3D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
1047 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
1048 | mipLevelSize(level, dimensions[1]), | - | ||||||||||||
1049 | 6 * layers, | - | ||||||||||||
1050 | 0, | - | ||||||||||||
1051 | pixelFormat, pixelType, 0); | - | ||||||||||||
1052 | } else { | - | ||||||||||||
1053 | QMessageLogger(__FILE__, 10901099, __PRETTY_FUNCTION__).warning("Cubemap Array textures are not supported"); | - | ||||||||||||
1054 | return; | - | ||||||||||||
1055 | } | - | ||||||||||||
1056 | break; | - | ||||||||||||
1057 | - | |||||||||||||
1058 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1059 | if (features.testFlag(QOpenGLTexture::Texture3D)) { | - | ||||||||||||
1060 | for (int level = 0; level < mipLevels; ++level) | - | ||||||||||||
1061 | texFuncs->glTextureImage3D(textureId, target, bindingTarget, level, format, | - | ||||||||||||
1062 | mipLevelSize(level, dimensions[0]), | - | ||||||||||||
1063 | mipLevelSize(level, dimensions[1]), | - | ||||||||||||
1064 | mipLevelSize(level, dimensions[2]), | - | ||||||||||||
1065 | 0, | - | ||||||||||||
1066 | pixelFormat, pixelType, 0); | - | ||||||||||||
1067 | } else { | - | ||||||||||||
1068 | QMessageLogger(__FILE__, 11051114, __PRETTY_FUNCTION__).warning("3D textures are not supported"); | - | ||||||||||||
1069 | return; | - | ||||||||||||
1070 | } | - | ||||||||||||
1071 | break; | - | ||||||||||||
1072 | - | |||||||||||||
1073 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1074 | if (features.testFlag(QOpenGLTexture::TextureMultisample)) { | - | ||||||||||||
1075 | texFuncs->glTextureImage2DMultisample(textureId, target, bindingTarget, samples, format, | - | ||||||||||||
1076 | dimensions[0], dimensions[1], | - | ||||||||||||
1077 | fixedSamplePositions); | - | ||||||||||||
1078 | } else { | - | ||||||||||||
1079 | QMessageLogger(__FILE__, 11161125, __PRETTY_FUNCTION__).warning("Multisample textures are not supported"); | - | ||||||||||||
1080 | return; | - | ||||||||||||
1081 | } | - | ||||||||||||
1082 | break; | - | ||||||||||||
1083 | - | |||||||||||||
1084 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1085 | if (features.testFlag(QOpenGLTexture::TextureMultisample) | - | ||||||||||||
1086 | && features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
1087 | texFuncs->glTextureImage3DMultisample(textureId, target, bindingTarget, samples, format, | - | ||||||||||||
1088 | dimensions[0], dimensions[1], layers, | - | ||||||||||||
1089 | fixedSamplePositions); | - | ||||||||||||
1090 | } else { | - | ||||||||||||
1091 | QMessageLogger(__FILE__, 11281137, __PRETTY_FUNCTION__).warning("Multisample array textures are not supported"); | - | ||||||||||||
1092 | return; | - | ||||||||||||
1093 | } | - | ||||||||||||
1094 | break; | - | ||||||||||||
1095 | } | - | ||||||||||||
1096 | - | |||||||||||||
1097 | storageAllocated = true; | - | ||||||||||||
1098 | } | - | ||||||||||||
1099 | - | |||||||||||||
1100 | void QOpenGLTexturePrivate::allocateImmutableStorage() | - | ||||||||||||
1101 | { | - | ||||||||||||
1102 | switch (target) { | - | ||||||||||||
1103 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1104 | - | |||||||||||||
1105 | QMessageLogger(__FILE__, 11421151, __PRETTY_FUNCTION__).warning("Buffer textures do not allocate storage"); | - | ||||||||||||
1106 | return; | - | ||||||||||||
1107 | - | |||||||||||||
1108 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1109 | if (features.testFlag(QOpenGLTexture::Texture1D)) { | - | ||||||||||||
1110 | texFuncs->glTextureStorage1D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1111 | dimensions[0]); | - | ||||||||||||
1112 | } else { | - | ||||||||||||
1113 | QMessageLogger(__FILE__, 11501159, __PRETTY_FUNCTION__).warning("1D textures are not supported"); | - | ||||||||||||
1114 | return; | - | ||||||||||||
1115 | } | - | ||||||||||||
1116 | break; | - | ||||||||||||
1117 | - | |||||||||||||
1118 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1119 | if (features.testFlag(QOpenGLTexture::Texture1D) | - | ||||||||||||
1120 | && features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
1121 | texFuncs->glTextureStorage2D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1122 | dimensions[0], layers); | - | ||||||||||||
1123 | } else { | - | ||||||||||||
1124 | QMessageLogger(__FILE__, 11611170, __PRETTY_FUNCTION__).warning("1D array textures are not supported"); | - | ||||||||||||
1125 | return; | - | ||||||||||||
1126 | } | - | ||||||||||||
1127 | break; | - | ||||||||||||
1128 | - | |||||||||||||
1129 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1130 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1131 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1132 | texFuncs->glTextureStorage2D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1133 | dimensions[0], dimensions[1]); | - | ||||||||||||
1134 | break; | - | ||||||||||||
1135 | - | |||||||||||||
1136 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1137 | if (features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
1138 | texFuncs->glTextureStorage3D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1139 | dimensions[0], dimensions[1], layers); | - | ||||||||||||
1140 | } else { | - | ||||||||||||
1141 | QMessageLogger(__FILE__, 11781187, __PRETTY_FUNCTION__).warning("Array textures are not supported"); | - | ||||||||||||
1142 | return; | - | ||||||||||||
1143 | } | - | ||||||||||||
1144 | break; | - | ||||||||||||
1145 | - | |||||||||||||
1146 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1147 | - | |||||||||||||
1148 | if (features.testFlag(QOpenGLTexture::TextureCubeMapArrays)) { | - | ||||||||||||
1149 | texFuncs->glTextureStorage3D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1150 | dimensions[0], dimensions[1], 6 * layers); | - | ||||||||||||
1151 | } else { | - | ||||||||||||
1152 | QMessageLogger(__FILE__, 11891198, __PRETTY_FUNCTION__).warning("Cubemap Array textures are not supported"); | - | ||||||||||||
1153 | return; | - | ||||||||||||
1154 | } | - | ||||||||||||
1155 | break; | - | ||||||||||||
1156 | - | |||||||||||||
1157 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1158 | if (features.testFlag(QOpenGLTexture::Texture3D)) { | - | ||||||||||||
1159 | texFuncs->glTextureStorage3D(textureId, target, bindingTarget, mipLevels, format, | - | ||||||||||||
1160 | dimensions[0], dimensions[1], dimensions[2]); | - | ||||||||||||
1161 | } else { | - | ||||||||||||
1162 | QMessageLogger(__FILE__, 11991208, __PRETTY_FUNCTION__).warning("3D textures are not supported"); | - | ||||||||||||
1163 | return; | - | ||||||||||||
1164 | } | - | ||||||||||||
1165 | break; | - | ||||||||||||
1166 | - | |||||||||||||
1167 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1168 | if (features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage)) { | - | ||||||||||||
1169 | texFuncs->glTextureStorage2DMultisample(textureId, target, bindingTarget, samples, format, | - | ||||||||||||
1170 | dimensions[0], dimensions[1], | - | ||||||||||||
1171 | fixedSamplePositions); | - | ||||||||||||
1172 | } else { | - | ||||||||||||
1173 | QMessageLogger(__FILE__, 12101219, __PRETTY_FUNCTION__).warning("Multisample textures are not supported"); | - | ||||||||||||
1174 | return; | - | ||||||||||||
1175 | } | - | ||||||||||||
1176 | break; | - | ||||||||||||
1177 | - | |||||||||||||
1178 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1179 | if (features.testFlag(QOpenGLTexture::ImmutableMultisampleStorage) | - | ||||||||||||
1180 | && features.testFlag(QOpenGLTexture::TextureArrays)) { | - | ||||||||||||
1181 | texFuncs->glTextureStorage3DMultisample(textureId, target, bindingTarget, samples, format, | - | ||||||||||||
1182 | dimensions[0], dimensions[1], layers, | - | ||||||||||||
1183 | fixedSamplePositions); | - | ||||||||||||
1184 | } else { | - | ||||||||||||
1185 | QMessageLogger(__FILE__, 12221231, __PRETTY_FUNCTION__).warning("Multisample array textures are not supported"); | - | ||||||||||||
1186 | return; | - | ||||||||||||
1187 | } | - | ||||||||||||
1188 | break; | - | ||||||||||||
1189 | } | - | ||||||||||||
1190 | - | |||||||||||||
1191 | storageAllocated = true; | - | ||||||||||||
1192 | } | - | ||||||||||||
1193 | - | |||||||||||||
1194 | void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, | - | ||||||||||||
1195 | QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, | - | ||||||||||||
1196 | const void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
1197 | { | - | ||||||||||||
1198 | switch (target) { | - | ||||||||||||
1199 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1200 | (void)layer;; | - | ||||||||||||
1201 | (void)cubeFace;; | - | ||||||||||||
1202 | texFuncs->glTextureSubImage1D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1203 | 0, mipLevelSize( mipLevel, dimensions[0] ), | - | ||||||||||||
1204 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1205 | break; | - | ||||||||||||
1206 | - | |||||||||||||
1207 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1208 | (void)cubeFace;; | - | ||||||||||||
1209 | texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1210 | 0, layer, | - | ||||||||||||
1211 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1212 | 1, | - | ||||||||||||
1213 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1214 | break; | - | ||||||||||||
1215 | - | |||||||||||||
1216 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1217 | (void)layer;; | - | ||||||||||||
1218 | (void)cubeFace;; | - | ||||||||||||
1219 | texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1220 | 0, 0, | - | ||||||||||||
1221 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1222 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1223 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1224 | break; | - | ||||||||||||
1225 | - | |||||||||||||
1226 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1227 | (void)cubeFace;; | - | ||||||||||||
1228 | texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1229 | 0, 0, layer, | - | ||||||||||||
1230 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1231 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1232 | 1, | - | ||||||||||||
1233 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1234 | break; | - | ||||||||||||
1235 | - | |||||||||||||
1236 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1237 | (void)cubeFace;; | - | ||||||||||||
1238 | texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1239 | 0, 0, layer, | - | ||||||||||||
1240 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1241 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1242 | mipLevelSize(mipLevel, dimensions[2]), | - | ||||||||||||
1243 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1244 | break; | - | ||||||||||||
1245 | - | |||||||||||||
1246 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1247 | (void)layer;; | - | ||||||||||||
1248 | texFuncs->glTextureSubImage2D(textureId, cubeFace, bindingTarget, mipLevel, | - | ||||||||||||
1249 | 0, 0, | - | ||||||||||||
1250 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1251 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1252 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1253 | break; | - | ||||||||||||
1254 | - | |||||||||||||
1255 | case QOpenGLTexture::TargetCubeMapArray: { | - | ||||||||||||
1256 | int faceIndex = cubeFace - QOpenGLTexture::CubeMapPositiveX; | - | ||||||||||||
1257 | int layerFace = 6 * layer + faceIndex; | - | ||||||||||||
1258 | texFuncs->glTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1259 | 0, 0, layerFace, | - | ||||||||||||
1260 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1261 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1262 | 1, | - | ||||||||||||
1263 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1264 | break; | - | ||||||||||||
1265 | } | - | ||||||||||||
1266 | - | |||||||||||||
1267 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1268 | (void)mipLevel;; | - | ||||||||||||
1269 | (void)layer;; | - | ||||||||||||
1270 | (void)cubeFace;; | - | ||||||||||||
1271 | texFuncs->glTextureSubImage2D(textureId, target, bindingTarget, 0, | - | ||||||||||||
1272 | 0, 0, | - | ||||||||||||
1273 | dimensions[0], | - | ||||||||||||
1274 | dimensions[1], | - | ||||||||||||
1275 | sourceFormat, sourceType, data, options); | - | ||||||||||||
1276 | break; | - | ||||||||||||
1277 | - | |||||||||||||
1278 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1279 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1280 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1281 | - | |||||||||||||
1282 | QMessageLogger(__FILE__, 13191328, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setData(): Texture target does not support pixel data upload"); | - | ||||||||||||
1283 | break; | - | ||||||||||||
1284 | } | - | ||||||||||||
1285 | - | |||||||||||||
1286 | - | |||||||||||||
1287 | if (mipLevel == 0 && autoGenerateMipMaps && mipLevels > 1) { | - | ||||||||||||
1288 | QOpenGLTexture * const q = q_func(); | - | ||||||||||||
1289 | q->generateMipMaps(); | - | ||||||||||||
1290 | } | - | ||||||||||||
1291 | } | - | ||||||||||||
1292 | - | |||||||||||||
1293 | void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTexture::CubeMapFace cubeFace, | - | ||||||||||||
1294 | int dataSize, const void *data, | - | ||||||||||||
1295 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
1296 | { | - | ||||||||||||
1297 | if (!isCompressedFormat(format)) { | - | ||||||||||||
1298 | QMessageLogger(__FILE__, 13351344, __PRETTY_FUNCTION__).warning("Cannot set compressed data for non-compressed format 0x%x", format); | - | ||||||||||||
1299 | return; | - | ||||||||||||
1300 | } | - | ||||||||||||
1301 | - | |||||||||||||
1302 | const bool needsFullSpec = !isUsingImmutableStorage(); | - | ||||||||||||
1303 | - | |||||||||||||
1304 | switch (target) { | - | ||||||||||||
1305 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1306 | (void)layer;; | - | ||||||||||||
1307 | (void)cubeFace;; | - | ||||||||||||
1308 | if (needsFullSpec) { | - | ||||||||||||
1309 | texFuncs->glCompressedTextureImage1D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1310 | format, | - | ||||||||||||
1311 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1312 | 0, dataSize, data, options); | - | ||||||||||||
1313 | } else { | - | ||||||||||||
1314 | texFuncs->glCompressedTextureSubImage1D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1315 | 0, mipLevelSize( mipLevel, dimensions[0] ), | - | ||||||||||||
1316 | format, dataSize, data, options); | - | ||||||||||||
1317 | } | - | ||||||||||||
1318 | break; | - | ||||||||||||
1319 | - | |||||||||||||
1320 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1321 | (void)cubeFace;; | - | ||||||||||||
1322 | if (!needsFullSpec) { | - | ||||||||||||
1323 | texFuncs->glCompressedTextureSubImage2D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1324 | 0, layer, | - | ||||||||||||
1325 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1326 | 1, | - | ||||||||||||
1327 | format, dataSize, data, options); | - | ||||||||||||
1328 | } | - | ||||||||||||
1329 | break; | - | ||||||||||||
1330 | - | |||||||||||||
1331 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1332 | (void)layer;; | - | ||||||||||||
1333 | (void)cubeFace;; | - | ||||||||||||
1334 | if (needsFullSpec) { | - | ||||||||||||
1335 | texFuncs->glCompressedTextureImage2D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1336 | format, | - | ||||||||||||
1337 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1338 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1339 | 0, dataSize, data, options); | - | ||||||||||||
1340 | } else { | - | ||||||||||||
1341 | texFuncs->glCompressedTextureSubImage2D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1342 | 0, 0, | - | ||||||||||||
1343 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1344 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1345 | format, dataSize, data, options); | - | ||||||||||||
1346 | } | - | ||||||||||||
1347 | break; | - | ||||||||||||
1348 | - | |||||||||||||
1349 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1350 | (void)cubeFace;; | - | ||||||||||||
1351 | if (!needsFullSpec) { | - | ||||||||||||
1352 | texFuncs->glCompressedTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1353 | 0, 0, layer, | - | ||||||||||||
1354 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1355 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1356 | 1, | - | ||||||||||||
1357 | format, dataSize, data, options); | - | ||||||||||||
1358 | } | - | ||||||||||||
1359 | break; | - | ||||||||||||
1360 | - | |||||||||||||
1361 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1362 | (void)cubeFace;; | - | ||||||||||||
1363 | if (needsFullSpec) { | - | ||||||||||||
1364 | texFuncs->glCompressedTextureImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1365 | format, | - | ||||||||||||
1366 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1367 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1368 | mipLevelSize(mipLevel, dimensions[2]), | - | ||||||||||||
1369 | 0, dataSize, data, options); | - | ||||||||||||
1370 | } else { | - | ||||||||||||
1371 | texFuncs->glCompressedTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1372 | 0, 0, layer, | - | ||||||||||||
1373 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1374 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1375 | mipLevelSize(mipLevel, dimensions[2]), | - | ||||||||||||
1376 | format, dataSize, data, options); | - | ||||||||||||
1377 | } | - | ||||||||||||
1378 | break; | - | ||||||||||||
1379 | - | |||||||||||||
1380 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1381 | (void)layer;; | - | ||||||||||||
1382 | if (needsFullSpec) { | - | ||||||||||||
1383 | texFuncs->glCompressedTextureImage2D(textureId, cubeFace, bindingTarget, mipLevel, | - | ||||||||||||
1384 | format, | - | ||||||||||||
1385 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1386 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1387 | 0, dataSize, data, options); | - | ||||||||||||
1388 | } else { | - | ||||||||||||
1389 | texFuncs->glCompressedTextureSubImage2D(textureId, cubeFace, bindingTarget, mipLevel, | - | ||||||||||||
1390 | 0, 0, | - | ||||||||||||
1391 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1392 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1393 | format, dataSize, data, options); | - | ||||||||||||
1394 | } | - | ||||||||||||
1395 | break; | - | ||||||||||||
1396 | - | |||||||||||||
1397 | case QOpenGLTexture::TargetCubeMapArray: { | - | ||||||||||||
1398 | int faceIndex = cubeFace - QOpenGLTexture::CubeMapPositiveX; | - | ||||||||||||
1399 | int layerFace = 6 * layer + faceIndex; | - | ||||||||||||
1400 | if (!needsFullSpec) { | - | ||||||||||||
1401 | texFuncs->glCompressedTextureSubImage3D(textureId, target, bindingTarget, mipLevel, | - | ||||||||||||
1402 | 0, 0, layerFace, | - | ||||||||||||
1403 | mipLevelSize(mipLevel, dimensions[0]), | - | ||||||||||||
1404 | mipLevelSize(mipLevel, dimensions[1]), | - | ||||||||||||
1405 | 1, | - | ||||||||||||
1406 | format, dataSize, data, options); | - | ||||||||||||
1407 | } | - | ||||||||||||
1408 | break; | - | ||||||||||||
1409 | } | - | ||||||||||||
1410 | - | |||||||||||||
1411 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1412 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1413 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1414 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1415 | - | |||||||||||||
1416 | QMessageLogger(__FILE__, 14531462, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setCompressedData(): Texture target does not support pixel data upload"); | - | ||||||||||||
1417 | break; | - | ||||||||||||
1418 | } | - | ||||||||||||
1419 | - | |||||||||||||
1420 | - | |||||||||||||
1421 | if (mipLevel == 0 && autoGenerateMipMaps && mipLevels > 1) { | - | ||||||||||||
1422 | QOpenGLTexture * const q = q_func(); | - | ||||||||||||
1423 | q->generateMipMaps(); | - | ||||||||||||
1424 | } | - | ||||||||||||
1425 | } | - | ||||||||||||
1426 | - | |||||||||||||
1427 | void QOpenGLTexturePrivate::setWrapMode(QOpenGLTexture::WrapMode mode) | - | ||||||||||||
1428 | { | - | ||||||||||||
1429 | switch (target) { | - | ||||||||||||
1430 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1431 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1432 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1433 | wrapModes[0] = mode; | - | ||||||||||||
1434 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2802, mode); | - | ||||||||||||
1435 | break; | - | ||||||||||||
1436 | - | |||||||||||||
1437 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1438 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1439 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1440 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1441 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1442 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1443 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1444 | wrapModes[0] = wrapModes[1] = mode; | - | ||||||||||||
1445 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2802, mode); | - | ||||||||||||
1446 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2803, mode); | - | ||||||||||||
1447 | break; | - | ||||||||||||
1448 | - | |||||||||||||
1449 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1450 | wrapModes[0] = wrapModes[1] = wrapModes[2] = mode; | - | ||||||||||||
1451 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2802, mode); | - | ||||||||||||
1452 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2803, mode); | - | ||||||||||||
1453 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x8072, mode); | - | ||||||||||||
1454 | break; | - | ||||||||||||
1455 | } | - | ||||||||||||
1456 | } | - | ||||||||||||
1457 | - | |||||||||||||
1458 | void QOpenGLTexturePrivate::setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode) | - | ||||||||||||
1459 | { | - | ||||||||||||
1460 | switch (target) { | - | ||||||||||||
1461 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1462 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1463 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1464 | switch (direction) { | - | ||||||||||||
1465 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1466 | wrapModes[0] = mode; | - | ||||||||||||
1467 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2802, mode); | - | ||||||||||||
1468 | break; | - | ||||||||||||
1469 | - | |||||||||||||
1470 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1471 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1472 | QMessageLogger(__FILE__, 15091518, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); | - | ||||||||||||
1473 | break; | - | ||||||||||||
1474 | } | - | ||||||||||||
1475 | break; | - | ||||||||||||
1476 | - | |||||||||||||
1477 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1478 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1479 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1480 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1481 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1482 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1483 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1484 | switch (direction) { | - | ||||||||||||
1485 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1486 | wrapModes[0] = mode; | - | ||||||||||||
1487 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2802, mode); | - | ||||||||||||
1488 | break; | - | ||||||||||||
1489 | - | |||||||||||||
1490 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1491 | wrapModes[1] = mode; | - | ||||||||||||
1492 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, 0x2803, mode); | - | ||||||||||||
1493 | break; | - | ||||||||||||
1494 | - | |||||||||||||
1495 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1496 | QMessageLogger(__FILE__, 15331542, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); | - | ||||||||||||
1497 | break; | - | ||||||||||||
1498 | } | - | ||||||||||||
1499 | break; | - | ||||||||||||
1500 | - | |||||||||||||
1501 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1502 | switch (direction) { | - | ||||||||||||
1503 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1504 | wrapModes[0] = mode; | - | ||||||||||||
1505 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, direction, mode); | - | ||||||||||||
1506 | break; | - | ||||||||||||
1507 | - | |||||||||||||
1508 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1509 | wrapModes[1] = mode; | - | ||||||||||||
1510 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, direction, mode); | - | ||||||||||||
1511 | break; | - | ||||||||||||
1512 | - | |||||||||||||
1513 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1514 | wrapModes[2] = mode; | - | ||||||||||||
1515 | texFuncs->glTextureParameteri(textureId, target, bindingTarget, direction, mode); | - | ||||||||||||
1516 | break; | - | ||||||||||||
1517 | } | - | ||||||||||||
1518 | break; | - | ||||||||||||
1519 | } | - | ||||||||||||
1520 | } | - | ||||||||||||
1521 | - | |||||||||||||
1522 | QOpenGLTexture::WrapMode QOpenGLTexturePrivate::wrapMode(QOpenGLTexture::CoordinateDirection direction) const | - | ||||||||||||
1523 | { | - | ||||||||||||
1524 | switch (target) { | - | ||||||||||||
1525 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1526 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1527 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1528 | switch (direction) { | - | ||||||||||||
1529 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1530 | return wrapModes[0]; | - | ||||||||||||
1531 | - | |||||||||||||
1532 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1533 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1534 | QMessageLogger(__FILE__, 15711580, __PRETTY_FUNCTION__).warning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); | - | ||||||||||||
1535 | return QOpenGLTexture::Repeat; | - | ||||||||||||
1536 | } | - | ||||||||||||
1537 | break; | - | ||||||||||||
1538 | - | |||||||||||||
1539 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1540 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1541 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1542 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1543 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1544 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1545 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1546 | switch (direction) { | - | ||||||||||||
1547 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1548 | return wrapModes[0]; | - | ||||||||||||
1549 | - | |||||||||||||
1550 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1551 | return wrapModes[1]; | - | ||||||||||||
1552 | - | |||||||||||||
1553 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1554 | QMessageLogger(__FILE__, 15911600, __PRETTY_FUNCTION__).warning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); | - | ||||||||||||
1555 | return QOpenGLTexture::Repeat; | - | ||||||||||||
1556 | } | - | ||||||||||||
1557 | break; | - | ||||||||||||
1558 | - | |||||||||||||
1559 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1560 | switch (direction) { | - | ||||||||||||
1561 | case QOpenGLTexture::DirectionS: | - | ||||||||||||
1562 | return wrapModes[0]; | - | ||||||||||||
1563 | - | |||||||||||||
1564 | case QOpenGLTexture::DirectionT: | - | ||||||||||||
1565 | return wrapModes[1]; | - | ||||||||||||
1566 | - | |||||||||||||
1567 | case QOpenGLTexture::DirectionR: | - | ||||||||||||
1568 | return wrapModes[2]; | - | ||||||||||||
1569 | } | - | ||||||||||||
1570 | break; | - | ||||||||||||
1571 | } | - | ||||||||||||
1572 | - | |||||||||||||
1573 | ((!(false)) ? qt_assert("false",__FILE__,16101619) : qt_noop()); | - | ||||||||||||
1574 | return QOpenGLTexture::Repeat; | - | ||||||||||||
1575 | } | - | ||||||||||||
1576 | - | |||||||||||||
1577 | QOpenGLTexture *QOpenGLTexturePrivate::createTextureView(QOpenGLTexture::Target viewTarget, | - | ||||||||||||
1578 | QOpenGLTexture::TextureFormat viewFormat, | - | ||||||||||||
1579 | int minimumMipmapLevel, int maximumMipmapLevel, | - | ||||||||||||
1580 | int minimumLayer, int maximumLayer) const | - | ||||||||||||
1581 | { | - | ||||||||||||
1582 | - | |||||||||||||
1583 | - | |||||||||||||
1584 | - | |||||||||||||
1585 | bool viewTargetCompatible = false; | - | ||||||||||||
1586 | switch (target) { | - | ||||||||||||
1587 | case QOpenGLTexture::Target1D: | - | ||||||||||||
1588 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
1589 | viewTargetCompatible = (viewTarget == QOpenGLTexture::Target1D | - | ||||||||||||
1590 | || viewTarget == QOpenGLTexture::Target1DArray); | - | ||||||||||||
1591 | break; | - | ||||||||||||
1592 | - | |||||||||||||
1593 | - | |||||||||||||
1594 | case QOpenGLTexture::Target2D: | - | ||||||||||||
1595 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
1596 | viewTargetCompatible = (viewTarget == QOpenGLTexture::Target2D | - | ||||||||||||
1597 | || viewTarget == QOpenGLTexture::Target2DArray); | - | ||||||||||||
1598 | break; | - | ||||||||||||
1599 | - | |||||||||||||
1600 | case QOpenGLTexture::Target3D: | - | ||||||||||||
1601 | viewTargetCompatible = (viewTarget == QOpenGLTexture::Target3D); | - | ||||||||||||
1602 | break; | - | ||||||||||||
1603 | - | |||||||||||||
1604 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
1605 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
1606 | viewTargetCompatible = (viewTarget == QOpenGLTexture::TargetCubeMap | - | ||||||||||||
1607 | || viewTarget == QOpenGLTexture::Target2D | - | ||||||||||||
1608 | || viewTarget == QOpenGLTexture::Target2DArray | - | ||||||||||||
1609 | || viewTarget == QOpenGLTexture::TargetCubeMapArray); | - | ||||||||||||
1610 | break; | - | ||||||||||||
1611 | - | |||||||||||||
1612 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
1613 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
1614 | viewTargetCompatible = (viewTarget == QOpenGLTexture::Target2DMultisample | - | ||||||||||||
1615 | || viewTarget == QOpenGLTexture::Target2DMultisampleArray); | - | ||||||||||||
1616 | break; | - | ||||||||||||
1617 | - | |||||||||||||
1618 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
1619 | viewTargetCompatible = (viewTarget == QOpenGLTexture::TargetRectangle); | - | ||||||||||||
1620 | break; | - | ||||||||||||
1621 | - | |||||||||||||
1622 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
1623 | - | |||||||||||||
1624 | break; | - | ||||||||||||
1625 | } | - | ||||||||||||
1626 | - | |||||||||||||
1627 | if (!viewTargetCompatible) { | - | ||||||||||||
1628 | QMessageLogger(__FILE__, 16651674, __PRETTY_FUNCTION__).warning("QOpenGLTexture::createTextureView(): Incompatible source and view targets"); | - | ||||||||||||
1629 | return 0; | - | ||||||||||||
1630 | } | - | ||||||||||||
1631 | - | |||||||||||||
1632 | - | |||||||||||||
1633 | bool viewFormatCompatible = false; | - | ||||||||||||
1634 | switch (formatClass) { | - | ||||||||||||
1635 | case QOpenGLTexture::NoFormatClass: | - | ||||||||||||
1636 | break; | - | ||||||||||||
1637 | - | |||||||||||||
1638 | case QOpenGLTexture::FormatClass_128Bit: | - | ||||||||||||
1639 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGBA32F | - | ||||||||||||
1640 | || viewFormat == QOpenGLTexture::RGBA32U | - | ||||||||||||
1641 | || viewFormat == QOpenGLTexture::RGBA32I); | - | ||||||||||||
1642 | break; | - | ||||||||||||
1643 | - | |||||||||||||
1644 | case QOpenGLTexture::FormatClass_96Bit: | - | ||||||||||||
1645 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB32F | - | ||||||||||||
1646 | || viewFormat == QOpenGLTexture::RGB32U | - | ||||||||||||
1647 | || viewFormat == QOpenGLTexture::RGB32I); | - | ||||||||||||
1648 | break; | - | ||||||||||||
1649 | - | |||||||||||||
1650 | case QOpenGLTexture::FormatClass_64Bit: | - | ||||||||||||
1651 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGBA16F | - | ||||||||||||
1652 | || viewFormat == QOpenGLTexture::RG32F | - | ||||||||||||
1653 | || viewFormat == QOpenGLTexture::RGBA16U | - | ||||||||||||
1654 | || viewFormat == QOpenGLTexture::RG32U | - | ||||||||||||
1655 | || viewFormat == QOpenGLTexture::RGBA16I | - | ||||||||||||
1656 | || viewFormat == QOpenGLTexture::RG32I | - | ||||||||||||
1657 | || viewFormat == QOpenGLTexture::RGBA16_UNorm | - | ||||||||||||
1658 | || viewFormat == QOpenGLTexture::RGBA16_SNorm); | - | ||||||||||||
1659 | break; | - | ||||||||||||
1660 | - | |||||||||||||
1661 | case QOpenGLTexture::FormatClass_48Bit: | - | ||||||||||||
1662 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB16_UNorm | - | ||||||||||||
1663 | || viewFormat == QOpenGLTexture::RGB16_SNorm | - | ||||||||||||
1664 | || viewFormat == QOpenGLTexture::RGB16F | - | ||||||||||||
1665 | || viewFormat == QOpenGLTexture::RGB16U | - | ||||||||||||
1666 | || viewFormat == QOpenGLTexture::RGB16I); | - | ||||||||||||
1667 | break; | - | ||||||||||||
1668 | - | |||||||||||||
1669 | case QOpenGLTexture::FormatClass_32Bit: | - | ||||||||||||
1670 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RG16F | - | ||||||||||||
1671 | || viewFormat == QOpenGLTexture::RG11B10F | - | ||||||||||||
1672 | || viewFormat == QOpenGLTexture::R32F | - | ||||||||||||
1673 | || viewFormat == QOpenGLTexture::RGB10A2 | - | ||||||||||||
1674 | || viewFormat == QOpenGLTexture::RGBA8U | - | ||||||||||||
1675 | || viewFormat == QOpenGLTexture::RG16U | - | ||||||||||||
1676 | || viewFormat == QOpenGLTexture::R32U | - | ||||||||||||
1677 | || viewFormat == QOpenGLTexture::RGBA8I | - | ||||||||||||
1678 | || viewFormat == QOpenGLTexture::RG16I | - | ||||||||||||
1679 | || viewFormat == QOpenGLTexture::R32I | - | ||||||||||||
1680 | || viewFormat == QOpenGLTexture::RGBA8_UNorm | - | ||||||||||||
1681 | || viewFormat == QOpenGLTexture::RG16_UNorm | - | ||||||||||||
1682 | || viewFormat == QOpenGLTexture::RGBA8_SNorm | - | ||||||||||||
1683 | || viewFormat == QOpenGLTexture::RG16_SNorm | - | ||||||||||||
1684 | || viewFormat == QOpenGLTexture::SRGB8_Alpha8 | - | ||||||||||||
1685 | || viewFormat == QOpenGLTexture::RGB9E5); | - | ||||||||||||
1686 | break; | - | ||||||||||||
1687 | - | |||||||||||||
1688 | case QOpenGLTexture::FormatClass_24Bit: | - | ||||||||||||
1689 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB8_UNorm | - | ||||||||||||
1690 | || viewFormat == QOpenGLTexture::RGB8_SNorm | - | ||||||||||||
1691 | || viewFormat == QOpenGLTexture::SRGB8 | - | ||||||||||||
1692 | || viewFormat == QOpenGLTexture::RGB8U | - | ||||||||||||
1693 | || viewFormat == QOpenGLTexture::RGB8I); | - | ||||||||||||
1694 | break; | - | ||||||||||||
1695 | - | |||||||||||||
1696 | case QOpenGLTexture::FormatClass_16Bit: | - | ||||||||||||
1697 | viewFormatCompatible = (viewFormat == QOpenGLTexture::R16F | - | ||||||||||||
1698 | || viewFormat == QOpenGLTexture::RG8U | - | ||||||||||||
1699 | || viewFormat == QOpenGLTexture::R16U | - | ||||||||||||
1700 | || viewFormat == QOpenGLTexture::RG8I | - | ||||||||||||
1701 | || viewFormat == QOpenGLTexture::R16I | - | ||||||||||||
1702 | || viewFormat == QOpenGLTexture::RG8_UNorm | - | ||||||||||||
1703 | || viewFormat == QOpenGLTexture::R16_UNorm | - | ||||||||||||
1704 | || viewFormat == QOpenGLTexture::RG8_SNorm | - | ||||||||||||
1705 | || viewFormat == QOpenGLTexture::R16_SNorm); | - | ||||||||||||
1706 | break; | - | ||||||||||||
1707 | - | |||||||||||||
1708 | case QOpenGLTexture::FormatClass_8Bit: | - | ||||||||||||
1709 | viewFormatCompatible = (viewFormat == QOpenGLTexture::R8U | - | ||||||||||||
1710 | || viewFormat == QOpenGLTexture::R8I | - | ||||||||||||
1711 | || viewFormat == QOpenGLTexture::R8_UNorm | - | ||||||||||||
1712 | || viewFormat == QOpenGLTexture::R8_SNorm); | - | ||||||||||||
1713 | break; | - | ||||||||||||
1714 | - | |||||||||||||
1715 | case QOpenGLTexture::FormatClass_RGTC1_R: | - | ||||||||||||
1716 | viewFormatCompatible = (viewFormat == QOpenGLTexture::R_ATI1N_UNorm | - | ||||||||||||
1717 | || viewFormat == QOpenGLTexture::R_ATI1N_SNorm); | - | ||||||||||||
1718 | break; | - | ||||||||||||
1719 | - | |||||||||||||
1720 | case QOpenGLTexture::FormatClass_RGTC2_RG: | - | ||||||||||||
1721 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RG_ATI2N_UNorm | - | ||||||||||||
1722 | || viewFormat == QOpenGLTexture::RG_ATI2N_SNorm); | - | ||||||||||||
1723 | break; | - | ||||||||||||
1724 | - | |||||||||||||
1725 | case QOpenGLTexture::FormatClass_BPTC_Unorm: | - | ||||||||||||
1726 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB_BP_UNorm | - | ||||||||||||
1727 | || viewFormat == QOpenGLTexture::SRGB_BP_UNorm); | - | ||||||||||||
1728 | break; | - | ||||||||||||
1729 | - | |||||||||||||
1730 | case QOpenGLTexture::FormatClass_BPTC_Float: | - | ||||||||||||
1731 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB_BP_UNSIGNED_FLOAT | - | ||||||||||||
1732 | || viewFormat == QOpenGLTexture::RGB_BP_SIGNED_FLOAT); | - | ||||||||||||
1733 | break; | - | ||||||||||||
1734 | - | |||||||||||||
1735 | case QOpenGLTexture::FormatClass_S3TC_DXT1_RGB: | - | ||||||||||||
1736 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGB_DXT1 | - | ||||||||||||
1737 | || viewFormat == QOpenGLTexture::SRGB_DXT1); | - | ||||||||||||
1738 | break; | - | ||||||||||||
1739 | - | |||||||||||||
1740 | case QOpenGLTexture::FormatClass_S3TC_DXT1_RGBA: | - | ||||||||||||
1741 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGBA_DXT1 | - | ||||||||||||
1742 | || viewFormat == QOpenGLTexture::SRGB_Alpha_DXT1); | - | ||||||||||||
1743 | break; | - | ||||||||||||
1744 | - | |||||||||||||
1745 | case QOpenGLTexture::FormatClass_S3TC_DXT3_RGBA: | - | ||||||||||||
1746 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGBA_DXT3 | - | ||||||||||||
1747 | || viewFormat == QOpenGLTexture::SRGB_Alpha_DXT3); | - | ||||||||||||
1748 | break; | - | ||||||||||||
1749 | - | |||||||||||||
1750 | case QOpenGLTexture::FormatClass_S3TC_DXT5_RGBA: | - | ||||||||||||
1751 | viewFormatCompatible = (viewFormat == QOpenGLTexture::RGBA_DXT5 | - | ||||||||||||
1752 | || viewFormat == QOpenGLTexture::SRGB_Alpha_DXT5); | - | ||||||||||||
1753 | break; | - | ||||||||||||
1754 | - | |||||||||||||
1755 | case QOpenGLTexture::FormatClass_Unique: | - | ||||||||||||
1756 | viewFormatCompatible = (viewFormat == format); | - | ||||||||||||
1757 | break; | - | ||||||||||||
1758 | } | - | ||||||||||||
1759 | - | |||||||||||||
1760 | if (!viewFormatCompatible) { | - | ||||||||||||
1761 | QMessageLogger(__FILE__, 17981807, __PRETTY_FUNCTION__).warning("QOpenGLTexture::createTextureView(): Incompatible source and view formats"); | - | ||||||||||||
1762 | return 0; | - | ||||||||||||
1763 | } | - | ||||||||||||
1764 | - | |||||||||||||
1765 | - | |||||||||||||
1766 | - | |||||||||||||
1767 | QOpenGLTexture *view = new QOpenGLTexture(viewTarget); | - | ||||||||||||
1768 | view->setFormat(viewFormat); | - | ||||||||||||
1769 | view->create(); | - | ||||||||||||
1770 | view->d_ptr->textureView = true; | - | ||||||||||||
1771 | texFuncs->glTextureView(view->textureId(), viewTarget, textureId, viewFormat, | - | ||||||||||||
1772 | minimumMipmapLevel, maximumMipmapLevel - minimumMipmapLevel + 1, | - | ||||||||||||
1773 | minimumLayer, maximumLayer - minimumLayer + 1); | - | ||||||||||||
1774 | return view; | - | ||||||||||||
1775 | } | - | ||||||||||||
1776 | QOpenGLTexture::QOpenGLTexture(Target target) | - | ||||||||||||
1777 | : d_ptr(new QOpenGLTexturePrivate(target, this)) | - | ||||||||||||
1778 | { | - | ||||||||||||
1779 | } | - | ||||||||||||
1780 | QOpenGLTexture::QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps) | - | ||||||||||||
1781 | : d_ptr(new QOpenGLTexturePrivate(QOpenGLTexture::Target2D, this)) | - | ||||||||||||
1782 | { | - | ||||||||||||
1783 | setData(image, genMipMaps); | - | ||||||||||||
1784 | } | - | ||||||||||||
1785 | - | |||||||||||||
1786 | QOpenGLTexture::~QOpenGLTexture() | - | ||||||||||||
1787 | { | - | ||||||||||||
1788 | } | - | ||||||||||||
1789 | - | |||||||||||||
1790 | - | |||||||||||||
1791 | - | |||||||||||||
1792 | - | |||||||||||||
1793 | - | |||||||||||||
1794 | - | |||||||||||||
1795 | QOpenGLTexture::Target QOpenGLTexture::target() const | - | ||||||||||||
1796 | { | - | ||||||||||||
1797 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1798 | return d->target; | - | ||||||||||||
1799 | } | - | ||||||||||||
1800 | bool QOpenGLTexture::create() | - | ||||||||||||
1801 | { | - | ||||||||||||
1802 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1803 | return d->create(); | - | ||||||||||||
1804 | } | - | ||||||||||||
1805 | - | |||||||||||||
1806 | - | |||||||||||||
1807 | - | |||||||||||||
1808 | - | |||||||||||||
1809 | - | |||||||||||||
1810 | - | |||||||||||||
1811 | - | |||||||||||||
1812 | void QOpenGLTexture::destroy() | - | ||||||||||||
1813 | { | - | ||||||||||||
1814 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1815 | return d->destroy(); | - | ||||||||||||
1816 | } | - | ||||||||||||
1817 | - | |||||||||||||
1818 | - | |||||||||||||
1819 | - | |||||||||||||
1820 | - | |||||||||||||
1821 | - | |||||||||||||
1822 | - | |||||||||||||
1823 | bool QOpenGLTexture::isCreated() const | - | ||||||||||||
1824 | { | - | ||||||||||||
1825 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1826 | return d->textureId != 0; | - | ||||||||||||
1827 | } | - | ||||||||||||
1828 | - | |||||||||||||
1829 | - | |||||||||||||
1830 | - | |||||||||||||
1831 | - | |||||||||||||
1832 | - | |||||||||||||
1833 | - | |||||||||||||
1834 | - | |||||||||||||
1835 | GLuint QOpenGLTexture::textureId() const | - | ||||||||||||
1836 | { | - | ||||||||||||
1837 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1838 | return d->textureId; | - | ||||||||||||
1839 | } | - | ||||||||||||
1840 | void QOpenGLTexture::bind() | - | ||||||||||||
1841 | { | - | ||||||||||||
1842 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1843 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,23002309) : qt_noop()); | - | ||||||||||||
1844 | d->bind(); | - | ||||||||||||
1845 | } | - | ||||||||||||
1846 | void QOpenGLTexture::bind(uint unit, TextureUnitReset reset) | - | ||||||||||||
1847 | { | - | ||||||||||||
1848 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1849 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,23192328) : qt_noop()); | - | ||||||||||||
1850 | d->bind(unit, reset); | - | ||||||||||||
1851 | } | - | ||||||||||||
1852 | - | |||||||||||||
1853 | - | |||||||||||||
1854 | - | |||||||||||||
1855 | - | |||||||||||||
1856 | - | |||||||||||||
1857 | - | |||||||||||||
1858 | void QOpenGLTexture::release() | - | ||||||||||||
1859 | { | - | ||||||||||||
1860 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1861 | d->release(); | - | ||||||||||||
1862 | } | - | ||||||||||||
1863 | void QOpenGLTexture::release(uint unit, TextureUnitReset reset) | - | ||||||||||||
1864 | { | - | ||||||||||||
1865 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1866 | d->release(unit, reset); | - | ||||||||||||
1867 | } | - | ||||||||||||
1868 | - | |||||||||||||
1869 | - | |||||||||||||
1870 | - | |||||||||||||
1871 | - | |||||||||||||
1872 | - | |||||||||||||
1873 | - | |||||||||||||
1874 | - | |||||||||||||
1875 | bool QOpenGLTexture::isBound() const | - | ||||||||||||
1876 | { | - | ||||||||||||
1877 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1878 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,23562365) : qt_noop()); | - | ||||||||||||
1879 | return d->isBound(); | - | ||||||||||||
1880 | } | - | ||||||||||||
1881 | - | |||||||||||||
1882 | - | |||||||||||||
1883 | - | |||||||||||||
1884 | - | |||||||||||||
1885 | - | |||||||||||||
1886 | - | |||||||||||||
1887 | - | |||||||||||||
1888 | bool QOpenGLTexture::isBound(uint unit) | - | ||||||||||||
1889 | { | - | ||||||||||||
1890 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1891 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,23692378) : qt_noop()); | - | ||||||||||||
1892 | return d->isBound(unit); | - | ||||||||||||
1893 | } | - | ||||||||||||
1894 | - | |||||||||||||
1895 | - | |||||||||||||
1896 | - | |||||||||||||
1897 | - | |||||||||||||
1898 | - | |||||||||||||
1899 | GLuint QOpenGLTexture::boundTextureId(BindingTarget target) | - | ||||||||||||
1900 | { | - | ||||||||||||
1901 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
1902 | if (!ctx) { | - | ||||||||||||
1903 | QMessageLogger(__FILE__, 23812390, __PRETTY_FUNCTION__).warning("QOpenGLTexture::boundTextureId() requires a valid current context"); | - | ||||||||||||
1904 | return 0; | - | ||||||||||||
1905 | } | - | ||||||||||||
1906 | - | |||||||||||||
1907 | GLint textureId = 0; | - | ||||||||||||
1908 | ctx->functions()->glGetIntegerv(target, &textureId); | - | ||||||||||||
1909 | return static_cast<GLuint>(textureId); | - | ||||||||||||
1910 | } | - | ||||||||||||
1911 | - | |||||||||||||
1912 | - | |||||||||||||
1913 | - | |||||||||||||
1914 | - | |||||||||||||
1915 | - | |||||||||||||
1916 | GLuint QOpenGLTexture::boundTextureId(uint unit, BindingTarget target) | - | ||||||||||||
1917 | { | - | ||||||||||||
1918 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
1919 | if (!ctx) { | - | ||||||||||||
1920 | QMessageLogger(__FILE__, 23982407, __PRETTY_FUNCTION__).warning("QOpenGLTexture::boundTextureId() requires a valid current context"); | - | ||||||||||||
1921 | return 0; | - | ||||||||||||
1922 | } | - | ||||||||||||
1923 | - | |||||||||||||
1924 | QOpenGLFunctions *funcs = ctx->functions(); | - | ||||||||||||
1925 | funcs->initializeOpenGLFunctions(); | - | ||||||||||||
1926 | - | |||||||||||||
1927 | GLint oldTextureUnit = 0; | - | ||||||||||||
1928 | funcs->glGetIntegerv(0x84E0, &oldTextureUnit); | - | ||||||||||||
1929 | - | |||||||||||||
1930 | funcs->glActiveTexture(unit); | - | ||||||||||||
1931 | GLint textureId = 0; | - | ||||||||||||
1932 | funcs->glGetIntegerv(target, &textureId); | - | ||||||||||||
1933 | funcs->glActiveTexture(oldTextureUnit); | - | ||||||||||||
1934 | - | |||||||||||||
1935 | return static_cast<GLuint>(textureId); | - | ||||||||||||
1936 | } | - | ||||||||||||
1937 | void QOpenGLTexture::setFormat(TextureFormat format) | - | ||||||||||||
1938 | { | - | ||||||||||||
1939 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
1940 | d->create(); | - | ||||||||||||
1941 | if (isStorageAllocated()) { | - | ||||||||||||
1942 | QMessageLogger(__FILE__, 24302439, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setFormat(): Cannot change format once storage has been allocated"); | - | ||||||||||||
1943 | return; | - | ||||||||||||
1944 | } | - | ||||||||||||
1945 | - | |||||||||||||
1946 | d->format = format; | - | ||||||||||||
1947 | - | |||||||||||||
1948 | switch (format) { | - | ||||||||||||
1949 | case NoFormat: | - | ||||||||||||
1950 | d->formatClass = NoFormatClass; | - | ||||||||||||
1951 | break; | - | ||||||||||||
1952 | - | |||||||||||||
1953 | case RGBA32F: | - | ||||||||||||
1954 | case RGBA32U: | - | ||||||||||||
1955 | case RGBA32I: | - | ||||||||||||
1956 | d->formatClass = FormatClass_128Bit; | - | ||||||||||||
1957 | break; | - | ||||||||||||
1958 | - | |||||||||||||
1959 | case RGB32F: | - | ||||||||||||
1960 | case RGB32U: | - | ||||||||||||
1961 | case RGB32I: | - | ||||||||||||
1962 | d->formatClass = FormatClass_96Bit; | - | ||||||||||||
1963 | break; | - | ||||||||||||
1964 | - | |||||||||||||
1965 | case RGBA16F: | - | ||||||||||||
1966 | case RG32F: | - | ||||||||||||
1967 | case RGBA16U: | - | ||||||||||||
1968 | case RG32U: | - | ||||||||||||
1969 | case RGBA16I: | - | ||||||||||||
1970 | case RG32I: | - | ||||||||||||
1971 | case RGBA16_UNorm: | - | ||||||||||||
1972 | case RGBA16_SNorm: | - | ||||||||||||
1973 | d->formatClass = FormatClass_64Bit; | - | ||||||||||||
1974 | break; | - | ||||||||||||
1975 | - | |||||||||||||
1976 | case RGB16_UNorm: | - | ||||||||||||
1977 | case RGB16_SNorm: | - | ||||||||||||
1978 | case RGB16F: | - | ||||||||||||
1979 | case RGB16U: | - | ||||||||||||
1980 | case RGB16I: | - | ||||||||||||
1981 | d->formatClass = FormatClass_48Bit; | - | ||||||||||||
1982 | break; | - | ||||||||||||
1983 | - | |||||||||||||
1984 | case RG16F: | - | ||||||||||||
1985 | case RG11B10F: | - | ||||||||||||
1986 | case R32F: | - | ||||||||||||
1987 | case RGB10A2: | - | ||||||||||||
1988 | case RGBA8U: | - | ||||||||||||
1989 | case RG16U: | - | ||||||||||||
1990 | case R32U: | - | ||||||||||||
1991 | case RGBA8I: | - | ||||||||||||
1992 | case RG16I: | - | ||||||||||||
1993 | case R32I: | - | ||||||||||||
1994 | case RGBA8_UNorm: | - | ||||||||||||
1995 | case RG16_UNorm: | - | ||||||||||||
1996 | case RGBA8_SNorm: | - | ||||||||||||
1997 | case RG16_SNorm: | - | ||||||||||||
1998 | case SRGB8_Alpha8: | - | ||||||||||||
1999 | case RGB9E5: | - | ||||||||||||
2000 | d->formatClass = FormatClass_32Bit; | - | ||||||||||||
2001 | break; | - | ||||||||||||
2002 | - | |||||||||||||
2003 | case RGB8_UNorm: | - | ||||||||||||
2004 | case RGB8_SNorm: | - | ||||||||||||
2005 | case SRGB8: | - | ||||||||||||
2006 | case RGB8U: | - | ||||||||||||
2007 | case RGB8I: | - | ||||||||||||
2008 | d->formatClass = FormatClass_24Bit; | - | ||||||||||||
2009 | break; | - | ||||||||||||
2010 | - | |||||||||||||
2011 | case R16F: | - | ||||||||||||
2012 | case RG8U: | - | ||||||||||||
2013 | case R16U: | - | ||||||||||||
2014 | case RG8I: | - | ||||||||||||
2015 | case R16I: | - | ||||||||||||
2016 | case RG8_UNorm: | - | ||||||||||||
2017 | case R16_UNorm: | - | ||||||||||||
2018 | case RG8_SNorm: | - | ||||||||||||
2019 | case R16_SNorm: | - | ||||||||||||
2020 | d->formatClass = FormatClass_16Bit; | - | ||||||||||||
2021 | break; | - | ||||||||||||
2022 | - | |||||||||||||
2023 | case R8U: | - | ||||||||||||
2024 | case R8I: | - | ||||||||||||
2025 | case R8_UNorm: | - | ||||||||||||
2026 | case R8_SNorm: | - | ||||||||||||
2027 | d->formatClass = FormatClass_8Bit; | - | ||||||||||||
2028 | break; | - | ||||||||||||
2029 | - | |||||||||||||
2030 | case R_ATI1N_UNorm: | - | ||||||||||||
2031 | case R_ATI1N_SNorm: | - | ||||||||||||
2032 | d->formatClass = FormatClass_RGTC1_R; | - | ||||||||||||
2033 | break; | - | ||||||||||||
2034 | - | |||||||||||||
2035 | case RG_ATI2N_UNorm: | - | ||||||||||||
2036 | case RG_ATI2N_SNorm: | - | ||||||||||||
2037 | d->formatClass = FormatClass_RGTC2_RG; | - | ||||||||||||
2038 | break; | - | ||||||||||||
2039 | - | |||||||||||||
2040 | case RGB_BP_UNorm: | - | ||||||||||||
2041 | case SRGB_BP_UNorm: | - | ||||||||||||
2042 | d->formatClass = FormatClass_BPTC_Unorm; | - | ||||||||||||
2043 | break; | - | ||||||||||||
2044 | - | |||||||||||||
2045 | case RGB_BP_UNSIGNED_FLOAT: | - | ||||||||||||
2046 | case RGB_BP_SIGNED_FLOAT: | - | ||||||||||||
2047 | d->formatClass = FormatClass_BPTC_Float; | - | ||||||||||||
2048 | break; | - | ||||||||||||
2049 | - | |||||||||||||
2050 | case RGB_DXT1: | - | ||||||||||||
2051 | case SRGB_DXT1: | - | ||||||||||||
2052 | d->formatClass = FormatClass_S3TC_DXT1_RGB; | - | ||||||||||||
2053 | break; | - | ||||||||||||
2054 | - | |||||||||||||
2055 | case RGBA_DXT1: | - | ||||||||||||
2056 | case SRGB_Alpha_DXT1: | - | ||||||||||||
2057 | d->formatClass = FormatClass_S3TC_DXT1_RGBA; | - | ||||||||||||
2058 | break; | - | ||||||||||||
2059 | - | |||||||||||||
2060 | case RGBA_DXT3: | - | ||||||||||||
2061 | case SRGB_Alpha_DXT3: | - | ||||||||||||
2062 | d->formatClass = FormatClass_S3TC_DXT3_RGBA; | - | ||||||||||||
2063 | break; | - | ||||||||||||
2064 | - | |||||||||||||
2065 | case RGBA_DXT5: | - | ||||||||||||
2066 | case SRGB_Alpha_DXT5: | - | ||||||||||||
2067 | d->formatClass = FormatClass_S3TC_DXT5_RGBA; | - | ||||||||||||
2068 | break; | - | ||||||||||||
2069 | - | |||||||||||||
2070 | case QOpenGLTexture::R11_EAC_UNorm: | - | ||||||||||||
2071 | case QOpenGLTexture::R11_EAC_SNorm: | - | ||||||||||||
2072 | case QOpenGLTexture::RG11_EAC_UNorm: | - | ||||||||||||
2073 | case QOpenGLTexture::RG11_EAC_SNorm: | - | ||||||||||||
2074 | case QOpenGLTexture::RGB8_ETC2: | - | ||||||||||||
2075 | case QOpenGLTexture::SRGB8_ETC2: | - | ||||||||||||
2076 | case QOpenGLTexture::RGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
2077 | case QOpenGLTexture::SRGB8_PunchThrough_Alpha1_ETC2: | - | ||||||||||||
2078 | case QOpenGLTexture::RGBA8_ETC2_EAC: | - | ||||||||||||
2079 | case QOpenGLTexture::SRGB8_Alpha8_ETC2_EAC: | - | ||||||||||||
2080 | case QOpenGLTexture::RGB8_ETC1: | - | ||||||||||||
2081 | case RG3B2: | - | ||||||||||||
2082 | case R5G6B5: | - | ||||||||||||
2083 | case RGB5A1: | - | ||||||||||||
2084 | case RGBA4: | - | ||||||||||||
2085 | case D16: | - | ||||||||||||
2086 | case D24: | - | ||||||||||||
2087 | case D24S8: | - | ||||||||||||
2088 | case D32: | - | ||||||||||||
2089 | case D32F: | - | ||||||||||||
2090 | case D32FS8X24: | - | ||||||||||||
2091 | case S8: | - | ||||||||||||
2092 | case DepthFormat: | - | ||||||||||||
2093 | case AlphaFormat: | - | ||||||||||||
2094 | case RGBFormat: | - | ||||||||||||
2095 | case RGBAFormat: | - | ||||||||||||
2096 | case LuminanceFormat: | - | ||||||||||||
2097 | case LuminanceAlphaFormat: | - | ||||||||||||
2098 | d->formatClass = FormatClass_Unique; | - | ||||||||||||
2099 | break; | - | ||||||||||||
2100 | } | - | ||||||||||||
2101 | } | - | ||||||||||||
2102 | - | |||||||||||||
2103 | - | |||||||||||||
2104 | - | |||||||||||||
2105 | - | |||||||||||||
2106 | - | |||||||||||||
2107 | - | |||||||||||||
2108 | QOpenGLTexture::TextureFormat QOpenGLTexture::format() const | - | ||||||||||||
2109 | { | - | ||||||||||||
2110 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2111 | return d->format; | - | ||||||||||||
2112 | } | - | ||||||||||||
2113 | void QOpenGLTexture::setSize(int width, int height, int depth) | - | ||||||||||||
2114 | { | - | ||||||||||||
2115 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2116 | d->create(); | - | ||||||||||||
2117 | if (isStorageAllocated()) { | - | ||||||||||||
2118 | QMessageLogger(__FILE__, 26162625, __PRETTY_FUNCTION__).warning("Cannot resize a texture that already has storage allocated.\n" | - | ||||||||||||
2119 | "To do so, destroy() the texture and then create() and setSize()"); | - | ||||||||||||
2120 | return; | - | ||||||||||||
2121 | } | - | ||||||||||||
2122 | - | |||||||||||||
2123 | switch (d->target) { | - | ||||||||||||
2124 | case QOpenGLTexture::Target1D: | - | ||||||||||||
2125 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
2126 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
2127 | d->dimensions[0] = width; | - | ||||||||||||
2128 | (void)height;; | - | ||||||||||||
2129 | (void)depth;; | - | ||||||||||||
2130 | break; | - | ||||||||||||
2131 | - | |||||||||||||
2132 | case QOpenGLTexture::Target2D: | - | ||||||||||||
2133 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
2134 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
2135 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
2136 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
2137 | d->dimensions[0] = width; | - | ||||||||||||
2138 | d->dimensions[1] = height; | - | ||||||||||||
2139 | (void)depth;; | - | ||||||||||||
2140 | break; | - | ||||||||||||
2141 | - | |||||||||||||
2142 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
2143 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
2144 | if (width != height) | - | ||||||||||||
2145 | QMessageLogger(__FILE__, 26432652, __PRETTY_FUNCTION__).warning("QAbstractOpenGLTexture::setSize(): Cube map textures must be square"); | - | ||||||||||||
2146 | d->dimensions[0] = d->dimensions[1] = width; | - | ||||||||||||
2147 | (void)depth;; | - | ||||||||||||
2148 | break; | - | ||||||||||||
2149 | - | |||||||||||||
2150 | case QOpenGLTexture::Target3D: | - | ||||||||||||
2151 | d->dimensions[0] = width; | - | ||||||||||||
2152 | d->dimensions[1] = height; | - | ||||||||||||
2153 | d->dimensions[2] = depth; | - | ||||||||||||
2154 | break; | - | ||||||||||||
2155 | } | - | ||||||||||||
2156 | } | - | ||||||||||||
2157 | - | |||||||||||||
2158 | - | |||||||||||||
2159 | - | |||||||||||||
2160 | - | |||||||||||||
2161 | - | |||||||||||||
2162 | - | |||||||||||||
2163 | int QOpenGLTexture::width() const | - | ||||||||||||
2164 | { | - | ||||||||||||
2165 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2166 | return d->dimensions[0]; | - | ||||||||||||
2167 | } | - | ||||||||||||
2168 | - | |||||||||||||
2169 | - | |||||||||||||
2170 | - | |||||||||||||
2171 | - | |||||||||||||
2172 | - | |||||||||||||
2173 | - | |||||||||||||
2174 | int QOpenGLTexture::height() const | - | ||||||||||||
2175 | { | - | ||||||||||||
2176 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2177 | return d->dimensions[1]; | - | ||||||||||||
2178 | } | - | ||||||||||||
2179 | - | |||||||||||||
2180 | - | |||||||||||||
2181 | - | |||||||||||||
2182 | - | |||||||||||||
2183 | - | |||||||||||||
2184 | - | |||||||||||||
2185 | int QOpenGLTexture::depth() const | - | ||||||||||||
2186 | { | - | ||||||||||||
2187 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2188 | return d->dimensions[2]; | - | ||||||||||||
2189 | } | - | ||||||||||||
2190 | void QOpenGLTexture::setMipLevels(int levels) | - | ||||||||||||
2191 | { | - | ||||||||||||
2192 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2193 | d->create(); | - | ||||||||||||
2194 | if (isStorageAllocated()) { | - | ||||||||||||
2195 | QMessageLogger(__FILE__, 27052714, __PRETTY_FUNCTION__).warning("Cannot set mip levels on a texture that already has storage allocated.\n" | - | ||||||||||||
2196 | "To do so, destroy() the texture and then create() and setMipLevels()"); | - | ||||||||||||
2197 | return; | - | ||||||||||||
2198 | } | - | ||||||||||||
2199 | - | |||||||||||||
2200 | switch (d->target) { | - | ||||||||||||
2201 | case QOpenGLTexture::Target1D: | - | ||||||||||||
2202 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
2203 | case QOpenGLTexture::Target2D: | - | ||||||||||||
2204 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
2205 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
2206 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
2207 | case QOpenGLTexture::Target3D: | - | ||||||||||||
2208 | d->requestedMipLevels = levels; | - | ||||||||||||
2209 | break; | - | ||||||||||||
2210 | - | |||||||||||||
2211 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
2212 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
2213 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
2214 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
2215 | QMessageLogger(__FILE__, 27252734, __PRETTY_FUNCTION__).warning("QAbstractOpenGLTexture::setMipLevels(): This texture target does not support mipmaps"); | - | ||||||||||||
2216 | break; | - | ||||||||||||
2217 | } | - | ||||||||||||
2218 | } | - | ||||||||||||
2219 | int QOpenGLTexture::mipLevels() const | - | ||||||||||||
2220 | { | - | ||||||||||||
2221 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2222 | return isStorageAllocated() ? d->mipLevels : d->requestedMipLevels; | - | ||||||||||||
2223 | } | - | ||||||||||||
2224 | - | |||||||||||||
2225 | - | |||||||||||||
2226 | - | |||||||||||||
2227 | - | |||||||||||||
2228 | - | |||||||||||||
2229 | - | |||||||||||||
2230 | - | |||||||||||||
2231 | int QOpenGLTexture::maximumMipLevels() const | - | ||||||||||||
2232 | { | - | ||||||||||||
2233 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2234 | return d->maximumMipLevelCount(); | - | ||||||||||||
2235 | } | - | ||||||||||||
2236 | void QOpenGLTexture::setLayers(int layers) | - | ||||||||||||
2237 | { | - | ||||||||||||
2238 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2239 | d->create(); | - | ||||||||||||
2240 | if (isStorageAllocated()) { | - | ||||||||||||
2241 | QMessageLogger(__FILE__, 27692778, __PRETTY_FUNCTION__).warning("Cannot set layers on a texture that already has storage allocated.\n" | - | ||||||||||||
2242 | "To do so, destroy() the texture and then create() and setLayers()"); | - | ||||||||||||
2243 | return; | - | ||||||||||||
2244 | } | - | ||||||||||||
2245 | - | |||||||||||||
2246 | switch (d->target) { | - | ||||||||||||
2247 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
2248 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
2249 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
2250 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
2251 | d->layers = layers; | - | ||||||||||||
2252 | break; | - | ||||||||||||
2253 | - | |||||||||||||
2254 | case QOpenGLTexture::Target1D: | - | ||||||||||||
2255 | case QOpenGLTexture::Target2D: | - | ||||||||||||
2256 | case QOpenGLTexture::Target3D: | - | ||||||||||||
2257 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
2258 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
2259 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
2260 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
2261 | QMessageLogger(__FILE__, 27892798, __PRETTY_FUNCTION__).warning("Texture target does not support array layers"); | - | ||||||||||||
2262 | break; | - | ||||||||||||
2263 | } | - | ||||||||||||
2264 | } | - | ||||||||||||
2265 | int QOpenGLTexture::layers() const | - | ||||||||||||
2266 | { | - | ||||||||||||
2267 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2268 | return d->layers; | - | ||||||||||||
2269 | } | - | ||||||||||||
2270 | - | |||||||||||||
2271 | - | |||||||||||||
2272 | - | |||||||||||||
2273 | - | |||||||||||||
2274 | - | |||||||||||||
2275 | - | |||||||||||||
2276 | - | |||||||||||||
2277 | int QOpenGLTexture::faces() const | - | ||||||||||||
2278 | { | - | ||||||||||||
2279 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2280 | return d->faces; | - | ||||||||||||
2281 | } | - | ||||||||||||
2282 | void QOpenGLTexture::setSamples(int samples) | - | ||||||||||||
2283 | { | - | ||||||||||||
2284 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2285 | d->create(); | - | ||||||||||||
2286 | if (isStorageAllocated()) { | - | ||||||||||||
2287 | QMessageLogger(__FILE__, 28372846, __PRETTY_FUNCTION__).warning("Cannot set sample count on a texture that already has storage allocated.\n" | - | ||||||||||||
2288 | "To do so, destroy() the texture and then create() and setSamples()"); | - | ||||||||||||
2289 | return; | - | ||||||||||||
2290 | } | - | ||||||||||||
2291 | - | |||||||||||||
2292 | switch (d->target) { | - | ||||||||||||
2293 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
2294 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
2295 | d->samples = samples; | - | ||||||||||||
2296 | break; | - | ||||||||||||
2297 | - | |||||||||||||
2298 | case QOpenGLTexture::Target1D: | - | ||||||||||||
2299 | case QOpenGLTexture::Target2D: | - | ||||||||||||
2300 | case QOpenGLTexture::Target3D: | - | ||||||||||||
2301 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
2302 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
2303 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
2304 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
2305 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
2306 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
2307 | - | |||||||||||||
2308 | QMessageLogger(__FILE__, 28582867, __PRETTY_FUNCTION__).warning("Texture target does not support multisampling"); | - | ||||||||||||
2309 | break; | - | ||||||||||||
2310 | } | - | ||||||||||||
2311 | } | - | ||||||||||||
2312 | int QOpenGLTexture::samples() const | - | ||||||||||||
2313 | { | - | ||||||||||||
2314 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2315 | return d->samples; | - | ||||||||||||
2316 | } | - | ||||||||||||
2317 | void QOpenGLTexture::setFixedSamplePositions(bool fixed) | - | ||||||||||||
2318 | { | - | ||||||||||||
2319 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2320 | d->create(); | - | ||||||||||||
2321 | if (isStorageAllocated()) { | - | ||||||||||||
2322 | QMessageLogger(__FILE__, 28992908, __PRETTY_FUNCTION__).warning("Cannot set sample positions on a texture that already has storage allocated.\n" | - | ||||||||||||
2323 | "To do so, destroy() the texture and then create() and setFixedSamplePositions()"); | - | ||||||||||||
2324 | return; | - | ||||||||||||
2325 | } | - | ||||||||||||
2326 | - | |||||||||||||
2327 | switch (d->target) { | - | ||||||||||||
2328 | case QOpenGLTexture::Target2DMultisample: | - | ||||||||||||
2329 | case QOpenGLTexture::Target2DMultisampleArray: | - | ||||||||||||
2330 | d->fixedSamplePositions = fixed; | - | ||||||||||||
2331 | break; | - | ||||||||||||
2332 | - | |||||||||||||
2333 | case QOpenGLTexture::Target1D: | - | ||||||||||||
2334 | case QOpenGLTexture::Target2D: | - | ||||||||||||
2335 | case QOpenGLTexture::Target3D: | - | ||||||||||||
2336 | case QOpenGLTexture::Target1DArray: | - | ||||||||||||
2337 | case QOpenGLTexture::Target2DArray: | - | ||||||||||||
2338 | case QOpenGLTexture::TargetCubeMap: | - | ||||||||||||
2339 | case QOpenGLTexture::TargetCubeMapArray: | - | ||||||||||||
2340 | case QOpenGLTexture::TargetBuffer: | - | ||||||||||||
2341 | case QOpenGLTexture::TargetRectangle: | - | ||||||||||||
2342 | - | |||||||||||||
2343 | QMessageLogger(__FILE__, 29202929, __PRETTY_FUNCTION__).warning("Texture target does not support multisampling"); | - | ||||||||||||
2344 | break; | - | ||||||||||||
2345 | } | - | ||||||||||||
2346 | } | - | ||||||||||||
2347 | bool QOpenGLTexture::isFixedSamplePositions() const | - | ||||||||||||
2348 | { | - | ||||||||||||
2349 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2350 | return d->fixedSamplePositions; | - | ||||||||||||
2351 | } | - | ||||||||||||
2352 | void QOpenGLTexture::allocateStorage() | - | ||||||||||||
2353 | { | - | ||||||||||||
2354 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2355 | if (d->create()) { | - | ||||||||||||
2356 | const QOpenGLTexture::PixelFormat pixelFormat = pixelFormatCompatibleWithInternalFormat(d->format); | - | ||||||||||||
2357 | const QOpenGLTexture::PixelType pixelType = pixelTypeCompatibleWithInternalFormat(d->format); | - | ||||||||||||
2358 | d->allocateStorage(pixelFormat, pixelType); | - | ||||||||||||
2359 | } | - | ||||||||||||
2360 | } | - | ||||||||||||
2361 | void QOpenGLTexture::allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) | - | ||||||||||||
2362 | { | - | ||||||||||||
2363 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2364 | if (d->create()) | - | ||||||||||||
2365 | d->allocateStorage(pixelFormat, pixelType); | - | ||||||||||||
2366 | } | - | ||||||||||||
2367 | bool QOpenGLTexture::isStorageAllocated() const | - | ||||||||||||
2368 | { | - | ||||||||||||
2369 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2370 | return d->storageAllocated; | - | ||||||||||||
2371 | } | - | ||||||||||||
2372 | QOpenGLTexture *QOpenGLTexture::createTextureView(Target target, | - | ||||||||||||
2373 | TextureFormat viewFormat, | - | ||||||||||||
2374 | int minimumMipmapLevel, int maximumMipmapLevel, | - | ||||||||||||
2375 | int minimumLayer, int maximumLayer) const | - | ||||||||||||
2376 | { | - | ||||||||||||
2377 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2378 | if (!isStorageAllocated()) { | - | ||||||||||||
2379 | QMessageLogger(__FILE__, 30603069, __PRETTY_FUNCTION__).warning("Cannot set create a texture view of a texture that does not have storage allocated."); | - | ||||||||||||
2380 | return 0; | - | ||||||||||||
2381 | } | - | ||||||||||||
2382 | ((!(maximumMipmapLevel >= minimumMipmapLevel)) ? qt_assert("maximumMipmapLevel >= minimumMipmapLevel",__FILE__,30633072) : qt_noop()); | - | ||||||||||||
2383 | ((!(maximumLayer >= minimumLayer)) ? qt_assert("maximumLayer >= minimumLayer",__FILE__,30643073) : qt_noop()); | - | ||||||||||||
2384 | return d->createTextureView(target, viewFormat, | - | ||||||||||||
2385 | minimumMipmapLevel, maximumMipmapLevel, | - | ||||||||||||
2386 | minimumLayer, maximumLayer); | - | ||||||||||||
2387 | } | - | ||||||||||||
2388 | - | |||||||||||||
2389 | - | |||||||||||||
2390 | - | |||||||||||||
2391 | - | |||||||||||||
2392 | - | |||||||||||||
2393 | - | |||||||||||||
2394 | - | |||||||||||||
2395 | bool QOpenGLTexture::isTextureView() const | - | ||||||||||||
2396 | { | - | ||||||||||||
2397 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2398 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,30793088) : qt_noop()); | - | ||||||||||||
2399 | return d->textureView; | - | ||||||||||||
2400 | } | - | ||||||||||||
2401 | void QOpenGLTexture::setData(int mipLevel, int layer, CubeMapFace cubeFace, | - | ||||||||||||
2402 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2403 | const void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2404 | { | - | ||||||||||||
2405 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2406 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31043113) : qt_noop()); | - | ||||||||||||
2407 | if (!isStorageAllocated()) { | - | ||||||||||||
2408 | QMessageLogger(__FILE__, 31063115, __PRETTY_FUNCTION__).warning("Cannot set data on a texture that does not have storage allocated.\n" | - | ||||||||||||
2409 | "To do so call allocateStorage() before this function"); | - | ||||||||||||
2410 | return; | - | ||||||||||||
2411 | } | - | ||||||||||||
2412 | d->setData(mipLevel, layer, cubeFace, sourceFormat, sourceType, data, options); | - | ||||||||||||
2413 | } | - | ||||||||||||
2414 | - | |||||||||||||
2415 | - | |||||||||||||
2416 | - | |||||||||||||
2417 | - | |||||||||||||
2418 | - | |||||||||||||
2419 | void QOpenGLTexture::setData(int mipLevel, int layer, | - | ||||||||||||
2420 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2421 | const void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2422 | { | - | ||||||||||||
2423 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2424 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31223131) : qt_noop()); | - | ||||||||||||
2425 | d->setData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2426 | } | - | ||||||||||||
2427 | - | |||||||||||||
2428 | - | |||||||||||||
2429 | - | |||||||||||||
2430 | - | |||||||||||||
2431 | - | |||||||||||||
2432 | void QOpenGLTexture::setData(int mipLevel, | - | ||||||||||||
2433 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2434 | const void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2435 | { | - | ||||||||||||
2436 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2437 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31353144) : qt_noop()); | - | ||||||||||||
2438 | d->setData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2439 | } | - | ||||||||||||
2440 | - | |||||||||||||
2441 | - | |||||||||||||
2442 | - | |||||||||||||
2443 | - | |||||||||||||
2444 | - | |||||||||||||
2445 | void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2446 | const void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2447 | { | - | ||||||||||||
2448 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2449 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31473156) : qt_noop()); | - | ||||||||||||
2450 | d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2451 | } | - | ||||||||||||
2452 | void QOpenGLTexture::setData(int mipLevel, int layer, CubeMapFace cubeFace, | - | ||||||||||||
2453 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2454 | void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2455 | { | - | ||||||||||||
2456 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2457 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31633172) : qt_noop()); | - | ||||||||||||
2458 | if (!isStorageAllocated()) { | - | ||||||||||||
2459 | QMessageLogger(__FILE__, 31653174, __PRETTY_FUNCTION__).warning("Cannot set data on a texture that does not have storage allocated.\n" | - | ||||||||||||
2460 | "To do so call allocateStorage() before this function"); | - | ||||||||||||
2461 | return; | - | ||||||||||||
2462 | } | - | ||||||||||||
2463 | d->setData(mipLevel, layer, cubeFace, sourceFormat, sourceType, data, options); | - | ||||||||||||
2464 | } | - | ||||||||||||
2465 | - | |||||||||||||
2466 | - | |||||||||||||
2467 | - | |||||||||||||
2468 | - | |||||||||||||
2469 | - | |||||||||||||
2470 | void QOpenGLTexture::setData(int mipLevel, int layer, | - | ||||||||||||
2471 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2472 | void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2473 | { | - | ||||||||||||
2474 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2475 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31813190) : qt_noop()); | - | ||||||||||||
2476 | d->setData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2477 | } | - | ||||||||||||
2478 | - | |||||||||||||
2479 | - | |||||||||||||
2480 | - | |||||||||||||
2481 | - | |||||||||||||
2482 | - | |||||||||||||
2483 | void QOpenGLTexture::setData(int mipLevel, | - | ||||||||||||
2484 | PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2485 | void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2486 | { | - | ||||||||||||
2487 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2488 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,31943203) : qt_noop()); | - | ||||||||||||
2489 | d->setData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2490 | } | - | ||||||||||||
2491 | - | |||||||||||||
2492 | - | |||||||||||||
2493 | - | |||||||||||||
2494 | - | |||||||||||||
2495 | - | |||||||||||||
2496 | void QOpenGLTexture::setData(PixelFormat sourceFormat, PixelType sourceType, | - | ||||||||||||
2497 | void *data, const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2498 | { | - | ||||||||||||
2499 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2500 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,32063215) : qt_noop()); | - | ||||||||||||
2501 | d->setData(0, 0, QOpenGLTexture::CubeMapPositiveX, sourceFormat, sourceType, data, options); | - | ||||||||||||
2502 | } | - | ||||||||||||
2503 | void QOpenGLTexture::setData(const QImage& image, MipMapGeneration genMipMaps) | - | ||||||||||||
2504 | { | - | ||||||||||||
2505 | QOpenGLContext *context = QOpenGLContext::currentContext(); | - | ||||||||||||
2506 | if (!context) { | - | ||||||||||||
2507 | QMessageLogger(__FILE__, 32223231, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setData() requires a valid current context"); | - | ||||||||||||
2508 | return; | - | ||||||||||||
2509 | } | - | ||||||||||||
2510 | - | |||||||||||||
2511 | if (image.isNull()) { | - | ||||||||||||
2512 | QMessageLogger(__FILE__, 32273236, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setData() tried to set a null image"); | - | ||||||||||||
2513 | return; | - | ||||||||||||
2514 | } | - | ||||||||||||
2515 | - | |||||||||||||
2516 | if (context->isOpenGLES() && context->format().majorVersion() < 3) | - | ||||||||||||
2517 | setFormat(QOpenGLTexture::RGBAFormat); | - | ||||||||||||
2518 | else | - | ||||||||||||
2519 | setFormat(QOpenGLTexture::RGBA8_UNorm); | - | ||||||||||||
2520 | - | |||||||||||||
2521 | setSize(image.width(), image.height()); | - | ||||||||||||
2522 | setMipLevels(genMipMaps == GenerateMipMaps ? maximumMipLevels() : 1); | - | ||||||||||||
2523 | allocateStorage(QOpenGLTexture::RGBA, QOpenGLTexture::UInt8); | - | ||||||||||||
2524 | - | |||||||||||||
2525 | - | |||||||||||||
2526 | QImage glImage = image.convertToFormat(QImage::Format_RGBA8888); | - | ||||||||||||
2527 | QOpenGLPixelTransferOptions uploadOptions; | - | ||||||||||||
2528 | uploadOptions.setAlignment(1); | - | ||||||||||||
2529 | setData(0, QOpenGLTexture::RGBA, QOpenGLTexture::UInt8, glImage.constBits(), &uploadOptions); | - | ||||||||||||
2530 | } | - | ||||||||||||
2531 | void QOpenGLTexture::setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace, | - | ||||||||||||
2532 | int dataSize, const void *data, | - | ||||||||||||
2533 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2534 | { | - | ||||||||||||
2535 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2536 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,32623271) : qt_noop()); | - | ||||||||||||
2537 | if (!isStorageAllocated()) { | - | ||||||||||||
2538 | QMessageLogger(__FILE__, 32643273, __PRETTY_FUNCTION__).warning("Cannot set data on a texture that does not have storage allocated.\n" | - | ||||||||||||
2539 | "To do so call allocateStorage() before this function"); | - | ||||||||||||
2540 | return; | - | ||||||||||||
2541 | } | - | ||||||||||||
2542 | d->setCompressedData(mipLevel, layer, cubeFace, dataSize, data, options); | - | ||||||||||||
2543 | } | - | ||||||||||||
2544 | - | |||||||||||||
2545 | - | |||||||||||||
2546 | - | |||||||||||||
2547 | - | |||||||||||||
2548 | void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int dataSize, const void *data, | - | ||||||||||||
2549 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2550 | { | - | ||||||||||||
2551 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2552 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,32783287) : qt_noop()); | - | ||||||||||||
2553 | d->setCompressedData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2554 | } | - | ||||||||||||
2555 | - | |||||||||||||
2556 | - | |||||||||||||
2557 | - | |||||||||||||
2558 | - | |||||||||||||
2559 | void QOpenGLTexture::setCompressedData(int mipLevel, int dataSize, const void *data, | - | ||||||||||||
2560 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2561 | { | - | ||||||||||||
2562 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2563 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,32893298) : qt_noop()); | - | ||||||||||||
2564 | d->setCompressedData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2565 | } | - | ||||||||||||
2566 | - | |||||||||||||
2567 | - | |||||||||||||
2568 | - | |||||||||||||
2569 | - | |||||||||||||
2570 | void QOpenGLTexture::setCompressedData(int dataSize, const void *data, | - | ||||||||||||
2571 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2572 | { | - | ||||||||||||
2573 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2574 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,33003309) : qt_noop()); | - | ||||||||||||
2575 | d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2576 | } | - | ||||||||||||
2577 | - | |||||||||||||
2578 | - | |||||||||||||
2579 | - | |||||||||||||
2580 | - | |||||||||||||
2581 | - | |||||||||||||
2582 | - | |||||||||||||
2583 | void QOpenGLTexture::setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace, | - | ||||||||||||
2584 | int dataSize, void *data, | - | ||||||||||||
2585 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2586 | { | - | ||||||||||||
2587 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2588 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,33143323) : qt_noop()); | - | ||||||||||||
2589 | if (!isStorageAllocated()) { | - | ||||||||||||
2590 | QMessageLogger(__FILE__, 33163325, __PRETTY_FUNCTION__).warning("Cannot set data on a texture that does not have storage allocated.\n" | - | ||||||||||||
2591 | "To do so call allocateStorage() before this function"); | - | ||||||||||||
2592 | return; | - | ||||||||||||
2593 | } | - | ||||||||||||
2594 | d->setCompressedData(mipLevel, layer, cubeFace, dataSize, data, options); | - | ||||||||||||
2595 | } | - | ||||||||||||
2596 | - | |||||||||||||
2597 | - | |||||||||||||
2598 | - | |||||||||||||
2599 | - | |||||||||||||
2600 | - | |||||||||||||
2601 | void QOpenGLTexture::setCompressedData(int mipLevel, int layer, int dataSize, void *data, | - | ||||||||||||
2602 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2603 | { | - | ||||||||||||
2604 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2605 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,33313340) : qt_noop()); | - | ||||||||||||
2606 | d->setCompressedData(mipLevel, layer, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2607 | } | - | ||||||||||||
2608 | - | |||||||||||||
2609 | - | |||||||||||||
2610 | - | |||||||||||||
2611 | - | |||||||||||||
2612 | - | |||||||||||||
2613 | void QOpenGLTexture::setCompressedData(int mipLevel, int dataSize, void *data, | - | ||||||||||||
2614 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2615 | { | - | ||||||||||||
2616 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2617 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,33433352) : qt_noop()); | - | ||||||||||||
2618 | d->setCompressedData(mipLevel, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2619 | } | - | ||||||||||||
2620 | - | |||||||||||||
2621 | - | |||||||||||||
2622 | - | |||||||||||||
2623 | - | |||||||||||||
2624 | - | |||||||||||||
2625 | void QOpenGLTexture::setCompressedData(int dataSize, void *data, | - | ||||||||||||
2626 | const QOpenGLPixelTransferOptions * const options) | - | ||||||||||||
2627 | { | - | ||||||||||||
2628 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2629 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,33553364) : qt_noop()); | - | ||||||||||||
2630 | d->setCompressedData(0, 0, QOpenGLTexture::CubeMapPositiveX, dataSize, data, options); | - | ||||||||||||
2631 | } | - | ||||||||||||
2632 | - | |||||||||||||
2633 | - | |||||||||||||
2634 | - | |||||||||||||
2635 | - | |||||||||||||
2636 | - | |||||||||||||
2637 | - | |||||||||||||
2638 | bool QOpenGLTexture::hasFeature(Feature feature) | - | ||||||||||||
2639 | { | - | ||||||||||||
2640 | QOpenGLContext *ctx = QOpenGLContext::currentContext(); | - | ||||||||||||
2641 | if (!ctx) { | - | ||||||||||||
2642 | QMessageLogger(__FILE__, 33683377, __PRETTY_FUNCTION__).warning("QOpenGLTexture::hasFeature() requires a valid current context"); | - | ||||||||||||
2643 | return false; | - | ||||||||||||
2644 | } | - | ||||||||||||
2645 | - | |||||||||||||
2646 | QSurfaceFormat f = ctx->format(); | - | ||||||||||||
2647 | - | |||||||||||||
2648 | bool supported = false; | - | ||||||||||||
2649 | - | |||||||||||||
2650 | - | |||||||||||||
2651 | if (!ctx->isOpenGLES()) { | - | ||||||||||||
2652 | switch (feature) { | - | ||||||||||||
2653 | case ImmutableMultisampleStorage: | - | ||||||||||||
2654 | supported = f.version() >= qMakePair(4, 3) | - | ||||||||||||
2655 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_storage_multisample") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_storage_multisample" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2656 | break; | - | ||||||||||||
2657 | - | |||||||||||||
2658 | case TextureBuffer: | - | ||||||||||||
2659 | supported = f.version() >= qMakePair(3, 0) | - | ||||||||||||
2660 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_buffer_object") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_buffer_object" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2661 | break; | - | ||||||||||||
2662 | - | |||||||||||||
2663 | case StencilTexturing: | - | ||||||||||||
2664 | supported = f.version() >= qMakePair(4, 3) | - | ||||||||||||
2665 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_stencil_texturing") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_stencil_texturing" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2666 | break; | - | ||||||||||||
2667 | - | |||||||||||||
2668 | case ImmutableStorage: | - | ||||||||||||
2669 | supported = f.version() >= qMakePair(4, 2) | - | ||||||||||||
2670 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_storage") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_storage" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())) | - | ||||||||||||
2671 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_texture_storage") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_texture_storage" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2672 | break; | - | ||||||||||||
2673 | - | |||||||||||||
2674 | case TextureCubeMapArrays: | - | ||||||||||||
2675 | supported = f.version() >= qMakePair(4, 0) | - | ||||||||||||
2676 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("ARB_texture_cube_map_array") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ARB_texture_cube_map_array" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2677 | break; | - | ||||||||||||
2678 | - | |||||||||||||
2679 | case Swizzle: | - | ||||||||||||
2680 | supported = f.version() >= qMakePair(3, 3) | - | ||||||||||||
2681 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_swizzle") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_swizzle" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2682 | break; | - | ||||||||||||
2683 | - | |||||||||||||
2684 | case TextureMultisample: | - | ||||||||||||
2685 | supported = f.version() >= qMakePair(3, 2) | - | ||||||||||||
2686 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_multisample") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_multisample" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2687 | break; | - | ||||||||||||
2688 | - | |||||||||||||
2689 | case TextureArrays: | - | ||||||||||||
2690 | supported = f.version() >= qMakePair(3, 0) | - | ||||||||||||
2691 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_texture_array") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_texture_array" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2692 | break; | - | ||||||||||||
2693 | - | |||||||||||||
2694 | case TextureRectangle: | - | ||||||||||||
2695 | supported = f.version() >= qMakePair(2, 1) | - | ||||||||||||
2696 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("ARB_texture_rectangle") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ARB_texture_rectangle" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2697 | break; | - | ||||||||||||
2698 | - | |||||||||||||
2699 | case Texture3D: | - | ||||||||||||
2700 | supported = f.version() >= qMakePair(1, 3); | - | ||||||||||||
2701 | break; | - | ||||||||||||
2702 | - | |||||||||||||
2703 | case AnisotropicFiltering: | - | ||||||||||||
2704 | supported = ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_texture_filter_anisotropic") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_texture_filter_anisotropic" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2705 | break; | - | ||||||||||||
2706 | - | |||||||||||||
2707 | case NPOTTextures: | - | ||||||||||||
2708 | case NPOTTextureRepeat: | - | ||||||||||||
2709 | supported = ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_non_power_of_two") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_non_power_of_two" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2710 | break; | - | ||||||||||||
2711 | - | |||||||||||||
2712 | case Texture1D: | - | ||||||||||||
2713 | supported = f.version() >= qMakePair(1, 1); | - | ||||||||||||
2714 | break; | - | ||||||||||||
2715 | - | |||||||||||||
2716 | case TextureComparisonOperators: | - | ||||||||||||
2717 | - | |||||||||||||
2718 | - | |||||||||||||
2719 | - | |||||||||||||
2720 | - | |||||||||||||
2721 | supported = f.version() >= qMakePair(1, 5) | - | ||||||||||||
2722 | || (ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_shadow") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_shadow" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())) | - | ||||||||||||
2723 | && ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_shadow_funcs") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_shadow_funcs" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))); | - | ||||||||||||
2724 | break; | - | ||||||||||||
2725 | - | |||||||||||||
2726 | case TextureMipMapLevel: | - | ||||||||||||
2727 | supported = f.version() >= qMakePair(1, 2); | - | ||||||||||||
2728 | break; | - | ||||||||||||
2729 | - | |||||||||||||
2730 | case MaxFeatureFlag: | - | ||||||||||||
2731 | break; | - | ||||||||||||
2732 | } | - | ||||||||||||
2733 | } | - | ||||||||||||
2734 | - | |||||||||||||
2735 | if (ctx->isOpenGLES()) | - | ||||||||||||
2736 | - | |||||||||||||
2737 | { | - | ||||||||||||
2738 | const char *renderer = reinterpret_cast<const char *>(ctx->functions()->glGetString(0x1F01)); | - | ||||||||||||
2739 | switch (feature) { | - | ||||||||||||
2740 | case ImmutableStorage: | - | ||||||||||||
2741 | supported = (f.version() >= qMakePair(3, 0) || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("EXT_texture_storage") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "EXT_texture_storage" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))) | - | ||||||||||||
2742 | && !(renderer && strstr(renderer, "Mali")); | - | ||||||||||||
2743 | break; | - | ||||||||||||
2744 | - | |||||||||||||
2745 | case ImmutableMultisampleStorage: | - | ||||||||||||
2746 | supported = f.version() >= qMakePair(3, 1); | - | ||||||||||||
2747 | break; | - | ||||||||||||
2748 | - | |||||||||||||
2749 | case TextureRectangle: | - | ||||||||||||
2750 | break; | - | ||||||||||||
2751 | - | |||||||||||||
2752 | case TextureArrays: | - | ||||||||||||
2753 | supported = f.version() >= qMakePair(3, 0); | - | ||||||||||||
2754 | break; | - | ||||||||||||
2755 | - | |||||||||||||
2756 | case Texture3D: | - | ||||||||||||
2757 | supported = f.version() >= qMakePair(3, 0) | - | ||||||||||||
2758 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_OES_texture_3D") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_OES_texture_3D" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2759 | break; | - | ||||||||||||
2760 | - | |||||||||||||
2761 | case TextureMultisample: | - | ||||||||||||
2762 | supported = f.version() >= qMakePair(3, 1); | - | ||||||||||||
2763 | break; | - | ||||||||||||
2764 | - | |||||||||||||
2765 | case TextureBuffer: | - | ||||||||||||
2766 | break; | - | ||||||||||||
2767 | - | |||||||||||||
2768 | case TextureCubeMapArrays: | - | ||||||||||||
2769 | break; | - | ||||||||||||
2770 | - | |||||||||||||
2771 | case Swizzle: | - | ||||||||||||
2772 | supported = f.version() >= qMakePair(3, 0); | - | ||||||||||||
2773 | break; | - | ||||||||||||
2774 | - | |||||||||||||
2775 | case StencilTexturing: | - | ||||||||||||
2776 | break; | - | ||||||||||||
2777 | - | |||||||||||||
2778 | case AnisotropicFiltering: | - | ||||||||||||
2779 | supported = ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_texture_filter_anisotropic") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_texture_filter_anisotropic" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2780 | break; | - | ||||||||||||
2781 | - | |||||||||||||
2782 | case NPOTTextures: | - | ||||||||||||
2783 | case NPOTTextureRepeat: | - | ||||||||||||
2784 | supported = f.version() >= qMakePair(3,0) | - | ||||||||||||
2785 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_OES_texture_npot") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_OES_texture_npot" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())) | - | ||||||||||||
2786 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_texture_non_power_of_two") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_texture_non_power_of_two" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2787 | break; | - | ||||||||||||
2788 | - | |||||||||||||
2789 | case Texture1D: | - | ||||||||||||
2790 | break; | - | ||||||||||||
2791 | - | |||||||||||||
2792 | case TextureComparisonOperators: | - | ||||||||||||
2793 | supported = f.version() >= qMakePair(3, 0) | - | ||||||||||||
2794 | || ctx->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_shadow_samplers") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_shadow_samplers" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }())); | - | ||||||||||||
2795 | break; | - | ||||||||||||
2796 | - | |||||||||||||
2797 | case TextureMipMapLevel: | - | ||||||||||||
2798 | supported = f.version() >= qMakePair(3, 0); | - | ||||||||||||
2799 | break; | - | ||||||||||||
2800 | - | |||||||||||||
2801 | case MaxFeatureFlag: | - | ||||||||||||
2802 | break; | - | ||||||||||||
2803 | } | - | ||||||||||||
2804 | } | - | ||||||||||||
2805 | - | |||||||||||||
2806 | return supported; | - | ||||||||||||
2807 | } | - | ||||||||||||
2808 | - | |||||||||||||
2809 | - | |||||||||||||
2810 | - | |||||||||||||
2811 | - | |||||||||||||
2812 | - | |||||||||||||
2813 | - | |||||||||||||
2814 | - | |||||||||||||
2815 | void QOpenGLTexture::setMipBaseLevel(int baseLevel) | - | ||||||||||||
2816 | { | - | ||||||||||||
2817 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2818 | d->create(); | - | ||||||||||||
2819 | if (!d->features.testFlag(TextureMipMapLevel)) { | - | ||||||||||||
2820 | QMessageLogger(__FILE__, 35463555, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setMipBaseLevel: requires OpenGL >= 1.2 or OpenGL ES >= 3.0"); | - | ||||||||||||
2821 | return; | - | ||||||||||||
2822 | } | - | ||||||||||||
2823 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,35493558) : qt_noop()); | - | ||||||||||||
2824 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,35503559) : qt_noop()); | - | ||||||||||||
2825 | ((!(baseLevel <= d->maxLevel)) ? qt_assert("baseLevel <= d->maxLevel",__FILE__,35513560) : qt_noop()); | - | ||||||||||||
2826 | d->baseLevel = baseLevel; | - | ||||||||||||
2827 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x813C, baseLevel); | - | ||||||||||||
2828 | } | - | ||||||||||||
2829 | - | |||||||||||||
2830 | - | |||||||||||||
2831 | - | |||||||||||||
2832 | - | |||||||||||||
2833 | - | |||||||||||||
2834 | - | |||||||||||||
2835 | - | |||||||||||||
2836 | int QOpenGLTexture::mipBaseLevel() const | - | ||||||||||||
2837 | { | - | ||||||||||||
2838 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2839 | return d->baseLevel; | - | ||||||||||||
2840 | } | - | ||||||||||||
2841 | - | |||||||||||||
2842 | - | |||||||||||||
2843 | - | |||||||||||||
2844 | - | |||||||||||||
2845 | - | |||||||||||||
2846 | - | |||||||||||||
2847 | - | |||||||||||||
2848 | void QOpenGLTexture::setMipMaxLevel(int maxLevel) | - | ||||||||||||
2849 | { | - | ||||||||||||
2850 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2851 | d->create(); | - | ||||||||||||
2852 | if (!d->features.testFlag(TextureMipMapLevel)) { | - | ||||||||||||
2853 | QMessageLogger(__FILE__, 35793588, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setMipMaxLevel: requires OpenGL >= 1.2 or OpenGL ES >= 3.0"); | - | ||||||||||||
2854 | return; | - | ||||||||||||
2855 | } | - | ||||||||||||
2856 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,35823591) : qt_noop()); | - | ||||||||||||
2857 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,35833592) : qt_noop()); | - | ||||||||||||
2858 | ((!(d->baseLevel <= maxLevel)) ? qt_assert("d->baseLevel <= maxLevel",__FILE__,35843593) : qt_noop()); | - | ||||||||||||
2859 | d->maxLevel = maxLevel; | - | ||||||||||||
2860 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x813D, maxLevel); | - | ||||||||||||
2861 | } | - | ||||||||||||
2862 | - | |||||||||||||
2863 | - | |||||||||||||
2864 | - | |||||||||||||
2865 | - | |||||||||||||
2866 | - | |||||||||||||
2867 | - | |||||||||||||
2868 | int QOpenGLTexture::mipMaxLevel() const | - | ||||||||||||
2869 | { | - | ||||||||||||
2870 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2871 | return d->maxLevel; | - | ||||||||||||
2872 | } | - | ||||||||||||
2873 | void QOpenGLTexture::setMipLevelRange(int baseLevel, int maxLevel) | - | ||||||||||||
2874 | { | - | ||||||||||||
2875 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2876 | d->create(); | - | ||||||||||||
2877 | if (!d->features.testFlag(TextureMipMapLevel)) { | - | ||||||||||||
2878 | QMessageLogger(__FILE__, 36123621, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setMipLevelRange: requires OpenGL >= 1.2 or OpenGL ES >= 3.0"); | - | ||||||||||||
2879 | return; | - | ||||||||||||
2880 | } | - | ||||||||||||
2881 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,36153624) : qt_noop()); | - | ||||||||||||
2882 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,36163625) : qt_noop()); | - | ||||||||||||
2883 | ((!(baseLevel <= maxLevel)) ? qt_assert("baseLevel <= maxLevel",__FILE__,36173626) : qt_noop()); | - | ||||||||||||
2884 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x813C, baseLevel); | - | ||||||||||||
2885 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x813D, maxLevel); | - | ||||||||||||
2886 | } | - | ||||||||||||
2887 | - | |||||||||||||
2888 | - | |||||||||||||
2889 | - | |||||||||||||
2890 | - | |||||||||||||
2891 | - | |||||||||||||
2892 | - | |||||||||||||
2893 | QPair<int, int> QOpenGLTexture::mipLevelRange() const | - | ||||||||||||
2894 | { | - | ||||||||||||
2895 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2896 | return qMakePair(d->baseLevel, d->maxLevel); | - | ||||||||||||
2897 | } | - | ||||||||||||
2898 | void QOpenGLTexture::setAutoMipMapGenerationEnabled(bool enabled) | - | ||||||||||||
2899 | { | - | ||||||||||||
2900 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2901 | d->autoGenerateMipMaps = enabled; | - | ||||||||||||
2902 | } | - | ||||||||||||
2903 | - | |||||||||||||
2904 | - | |||||||||||||
2905 | - | |||||||||||||
2906 | - | |||||||||||||
2907 | - | |||||||||||||
2908 | - | |||||||||||||
2909 | bool QOpenGLTexture::isAutoMipMapGenerationEnabled() const | - | ||||||||||||
2910 | { | - | ||||||||||||
2911 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2912 | return d->autoGenerateMipMaps; | - | ||||||||||||
2913 | } | - | ||||||||||||
2914 | void QOpenGLTexture::generateMipMaps() | - | ||||||||||||
2915 | { | - | ||||||||||||
2916 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2917 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,36743683) : qt_noop()); | - | ||||||||||||
2918 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,36753684) : qt_noop()); | - | ||||||||||||
2919 | if (isCompressedFormat(d->format)) { | - | ||||||||||||
2920 | if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) | - | ||||||||||||
2921 | if (ctx->isOpenGLES() && ctx->format().majorVersion() < 3) | - | ||||||||||||
2922 | return; | - | ||||||||||||
2923 | } | - | ||||||||||||
2924 | d->texFuncs->glGenerateTextureMipmap(d->textureId, d->target, d->bindingTarget); | - | ||||||||||||
2925 | } | - | ||||||||||||
2926 | void QOpenGLTexture::generateMipMaps(int baseLevel, bool resetBaseLevel) | - | ||||||||||||
2927 | { | - | ||||||||||||
2928 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2929 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,36993708) : qt_noop()); | - | ||||||||||||
2930 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,37003709) : qt_noop()); | - | ||||||||||||
2931 | if (isCompressedFormat(d->format)) { | - | ||||||||||||
2932 | if (QOpenGLContext *ctx = QOpenGLContext::currentContext()) | - | ||||||||||||
2933 | if (ctx->isOpenGLES() && ctx->format().majorVersion() < 3) | - | ||||||||||||
2934 | return; | - | ||||||||||||
2935 | } | - | ||||||||||||
2936 | int oldBaseLevel; | - | ||||||||||||
2937 | if (resetBaseLevel) | - | ||||||||||||
2938 | oldBaseLevel = mipBaseLevel(); | - | ||||||||||||
2939 | setMipBaseLevel(baseLevel); | - | ||||||||||||
2940 | d->texFuncs->glGenerateTextureMipmap(d->textureId, d->target, d->bindingTarget); | - | ||||||||||||
2941 | if (resetBaseLevel) | - | ||||||||||||
2942 | setMipBaseLevel(oldBaseLevel); | - | ||||||||||||
2943 | } | - | ||||||||||||
2944 | void QOpenGLTexture::setSwizzleMask(SwizzleComponent component, SwizzleValue value) | - | ||||||||||||
2945 | { | - | ||||||||||||
2946 | - | |||||||||||||
2947 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
2948 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2949 | d->create(); | - | ||||||||||||
2950 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,37333742) : qt_noop()); | - | ||||||||||||
2951 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,37343743) : qt_noop()); | - | ||||||||||||
2952 | if (!d->features.testFlag(Swizzle)) { | - | ||||||||||||
2953 | QMessageLogger(__FILE__, 37363745, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setSwizzleMask() requires OpenGL >= 3.3"); | - | ||||||||||||
2954 | return; | - | ||||||||||||
2955 | } | - | ||||||||||||
2956 | d->swizzleMask[component - SwizzleRed] = value; | - | ||||||||||||
2957 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, component, value); | - | ||||||||||||
2958 | return; | - | ||||||||||||
2959 | } | - | ||||||||||||
2960 | - | |||||||||||||
2961 | - | |||||||||||||
2962 | - | |||||||||||||
2963 | - | |||||||||||||
2964 | QMessageLogger(__FILE__, 37473756, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Texture swizzling is not supported"); | - | ||||||||||||
2965 | } | - | ||||||||||||
2966 | - | |||||||||||||
2967 | - | |||||||||||||
2968 | - | |||||||||||||
2969 | - | |||||||||||||
2970 | - | |||||||||||||
2971 | - | |||||||||||||
2972 | void QOpenGLTexture::setSwizzleMask(SwizzleValue r, SwizzleValue g, | - | ||||||||||||
2973 | SwizzleValue b, SwizzleValue a) | - | ||||||||||||
2974 | { | - | ||||||||||||
2975 | - | |||||||||||||
2976 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
2977 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
2978 | d->create(); | - | ||||||||||||
2979 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,37623771) : qt_noop()); | - | ||||||||||||
2980 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,37633772) : qt_noop()); | - | ||||||||||||
2981 | if (!d->features.testFlag(Swizzle)) { | - | ||||||||||||
2982 | QMessageLogger(__FILE__, 37653774, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setSwizzleMask() requires OpenGL >= 3.3"); | - | ||||||||||||
2983 | return; | - | ||||||||||||
2984 | } | - | ||||||||||||
2985 | GLint swizzleMask[] = {GLint(r), GLint(g), GLint(b), GLint(a)}; | - | ||||||||||||
2986 | d->swizzleMask[0] = r; | - | ||||||||||||
2987 | d->swizzleMask[1] = g; | - | ||||||||||||
2988 | d->swizzleMask[2] = b; | - | ||||||||||||
2989 | d->swizzleMask[3] = a; | - | ||||||||||||
2990 | d->texFuncs->glTextureParameteriv(d->textureId, d->target, d->bindingTarget, 0x8E46, swizzleMask); | - | ||||||||||||
2991 | return; | - | ||||||||||||
2992 | } | - | ||||||||||||
2993 | - | |||||||||||||
2994 | - | |||||||||||||
2995 | - | |||||||||||||
2996 | - | |||||||||||||
2997 | - | |||||||||||||
2998 | - | |||||||||||||
2999 | QMessageLogger(__FILE__, 37823791, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Texture swizzling is not supported"); | - | ||||||||||||
3000 | } | - | ||||||||||||
3001 | - | |||||||||||||
3002 | - | |||||||||||||
3003 | - | |||||||||||||
3004 | - | |||||||||||||
3005 | QOpenGLTexture::SwizzleValue QOpenGLTexture::swizzleMask(SwizzleComponent component) const | - | ||||||||||||
3006 | { | - | ||||||||||||
3007 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3008 | return d->swizzleMask[component - SwizzleRed]; | - | ||||||||||||
3009 | } | - | ||||||||||||
3010 | void QOpenGLTexture::setDepthStencilMode(QOpenGLTexture::DepthStencilMode mode) | - | ||||||||||||
3011 | { | - | ||||||||||||
3012 | - | |||||||||||||
3013 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3014 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3015 | d->create(); | - | ||||||||||||
3016 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,38223831) : qt_noop()); | - | ||||||||||||
3017 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,38233832) : qt_noop()); | - | ||||||||||||
3018 | if (!d->features.testFlag(StencilTexturing)) { | - | ||||||||||||
3019 | QMessageLogger(__FILE__, 38253834, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setDepthStencilMode() requires OpenGL >= 4.3 or GL_ARB_stencil_texturing"); | - | ||||||||||||
3020 | return; | - | ||||||||||||
3021 | } | - | ||||||||||||
3022 | d->depthStencilMode = mode; | - | ||||||||||||
3023 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x90EA, mode); | - | ||||||||||||
3024 | return; | - | ||||||||||||
3025 | } | - | ||||||||||||
3026 | - | |||||||||||||
3027 | - | |||||||||||||
3028 | - | |||||||||||||
3029 | QMessageLogger(__FILE__, 38353844, __PRETTY_FUNCTION__).warning("QOpenGLTexture: DepthStencil Mode is not supported"); | - | ||||||||||||
3030 | } | - | ||||||||||||
3031 | - | |||||||||||||
3032 | - | |||||||||||||
3033 | - | |||||||||||||
3034 | - | |||||||||||||
3035 | - | |||||||||||||
3036 | - | |||||||||||||
3037 | - | |||||||||||||
3038 | QOpenGLTexture::DepthStencilMode QOpenGLTexture::depthStencilMode() const | - | ||||||||||||
3039 | { | - | ||||||||||||
3040 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3041 | return d->depthStencilMode; | - | ||||||||||||
3042 | } | - | ||||||||||||
3043 | void QOpenGLTexture::setComparisonFunction(QOpenGLTexture::ComparisonFunction function) | - | ||||||||||||
3044 | { | - | ||||||||||||
3045 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3046 | d->create(); | - | ||||||||||||
3047 | if (!d->features.testFlag(TextureComparisonOperators)) { | - | ||||||||||||
3048 | QMessageLogger(__FILE__, 38803889, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setComparisonFunction: requires OpenGL >= 1.5 or OpenGL ES >= 3.0"); | - | ||||||||||||
3049 | return; | - | ||||||||||||
3050 | } | - | ||||||||||||
3051 | d->comparisonFunction = function; | - | ||||||||||||
3052 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x884D, function); | - | ||||||||||||
3053 | } | - | ||||||||||||
3054 | QOpenGLTexture::ComparisonFunction QOpenGLTexture::comparisonFunction() const | - | ||||||||||||
3055 | { | - | ||||||||||||
3056 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3057 | return d->comparisonFunction; | - | ||||||||||||
3058 | } | - | ||||||||||||
3059 | void QOpenGLTexture::setComparisonMode(QOpenGLTexture::ComparisonMode mode) | - | ||||||||||||
3060 | { | - | ||||||||||||
3061 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3062 | d->create(); | - | ||||||||||||
3063 | if (!d->features.testFlag(TextureComparisonOperators)) { | - | ||||||||||||
3064 | QMessageLogger(__FILE__, 39233932, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setComparisonMode: requires OpenGL >= 1.5 or OpenGL ES >= 3.0"); | - | ||||||||||||
3065 | return; | - | ||||||||||||
3066 | } | - | ||||||||||||
3067 | d->comparisonMode = mode; | - | ||||||||||||
3068 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x884C, mode); | - | ||||||||||||
3069 | } | - | ||||||||||||
3070 | QOpenGLTexture::ComparisonMode QOpenGLTexture::comparisonMode() const | - | ||||||||||||
3071 | { | - | ||||||||||||
3072 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3073 | return d->comparisonMode; | - | ||||||||||||
3074 | } | - | ||||||||||||
3075 | - | |||||||||||||
3076 | - | |||||||||||||
3077 | - | |||||||||||||
3078 | - | |||||||||||||
3079 | - | |||||||||||||
3080 | - | |||||||||||||
3081 | void QOpenGLTexture::setMinificationFilter(QOpenGLTexture::Filter filter) | - | ||||||||||||
3082 | { | - | ||||||||||||
3083 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3084 | d->create(); | - | ||||||||||||
3085 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,39533962) : qt_noop()); | - | ||||||||||||
3086 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,39543963) : qt_noop()); | - | ||||||||||||
3087 | d->minFilter = filter; | - | ||||||||||||
3088 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x2801, filter); | - | ||||||||||||
3089 | } | - | ||||||||||||
3090 | - | |||||||||||||
3091 | - | |||||||||||||
3092 | - | |||||||||||||
3093 | - | |||||||||||||
3094 | - | |||||||||||||
3095 | - | |||||||||||||
3096 | QOpenGLTexture::Filter QOpenGLTexture::minificationFilter() const | - | ||||||||||||
3097 | { | - | ||||||||||||
3098 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3099 | return d->minFilter; | - | ||||||||||||
3100 | } | - | ||||||||||||
3101 | - | |||||||||||||
3102 | - | |||||||||||||
3103 | - | |||||||||||||
3104 | - | |||||||||||||
3105 | - | |||||||||||||
3106 | - | |||||||||||||
3107 | void QOpenGLTexture::setMagnificationFilter(QOpenGLTexture::Filter filter) | - | ||||||||||||
3108 | { | - | ||||||||||||
3109 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3110 | d->create(); | - | ||||||||||||
3111 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,39793988) : qt_noop()); | - | ||||||||||||
3112 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,39803989) : qt_noop()); | - | ||||||||||||
3113 | d->magFilter = filter; | - | ||||||||||||
3114 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x2800, filter); | - | ||||||||||||
3115 | } | - | ||||||||||||
3116 | - | |||||||||||||
3117 | - | |||||||||||||
3118 | - | |||||||||||||
3119 | - | |||||||||||||
3120 | - | |||||||||||||
3121 | - | |||||||||||||
3122 | QOpenGLTexture::Filter QOpenGLTexture::magnificationFilter() const | - | ||||||||||||
3123 | { | - | ||||||||||||
3124 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3125 | return d->magFilter; | - | ||||||||||||
3126 | } | - | ||||||||||||
3127 | - | |||||||||||||
3128 | - | |||||||||||||
3129 | - | |||||||||||||
3130 | - | |||||||||||||
3131 | - | |||||||||||||
3132 | - | |||||||||||||
3133 | - | |||||||||||||
3134 | void QOpenGLTexture::setMinMagFilters(QOpenGLTexture::Filter minificationFilter, | - | ||||||||||||
3135 | QOpenGLTexture::Filter magnificationFilter) | - | ||||||||||||
3136 | { | - | ||||||||||||
3137 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3138 | d->create(); | - | ||||||||||||
3139 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,40074016) : qt_noop()); | - | ||||||||||||
3140 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,40084017) : qt_noop()); | - | ||||||||||||
3141 | d->minFilter = minificationFilter; | - | ||||||||||||
3142 | d->magFilter = magnificationFilter; | - | ||||||||||||
3143 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x2801, minificationFilter); | - | ||||||||||||
3144 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x2800, magnificationFilter); | - | ||||||||||||
3145 | } | - | ||||||||||||
3146 | - | |||||||||||||
3147 | - | |||||||||||||
3148 | - | |||||||||||||
3149 | - | |||||||||||||
3150 | - | |||||||||||||
3151 | - | |||||||||||||
3152 | QPair<QOpenGLTexture::Filter, QOpenGLTexture::Filter> QOpenGLTexture::minMagFilters() const | - | ||||||||||||
3153 | { | - | ||||||||||||
3154 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3155 | return QPair<QOpenGLTexture::Filter, QOpenGLTexture::Filter>(d->minFilter, d->magFilter); | - | ||||||||||||
3156 | } | - | ||||||||||||
3157 | - | |||||||||||||
3158 | - | |||||||||||||
3159 | - | |||||||||||||
3160 | - | |||||||||||||
3161 | - | |||||||||||||
3162 | - | |||||||||||||
3163 | - | |||||||||||||
3164 | void QOpenGLTexture::setMaximumAnisotropy(float anisotropy) | - | ||||||||||||
3165 | { | - | ||||||||||||
3166 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3167 | d->create(); | - | ||||||||||||
3168 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,40364045) : qt_noop()); | - | ||||||||||||
3169 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,40374046) : qt_noop()); | - | ||||||||||||
3170 | if (!d->features.testFlag(AnisotropicFiltering)) { | - | ||||||||||||
3171 | QMessageLogger(__FILE__, 40394048, __PRETTY_FUNCTION__).warning("QOpenGLTexture::setMaximumAnisotropy() requires GL_EXT_texture_filter_anisotropic"); | - | ||||||||||||
3172 | return; | - | ||||||||||||
3173 | } | - | ||||||||||||
3174 | d->maxAnisotropy = anisotropy; | - | ||||||||||||
3175 | d->texFuncs->glTextureParameteri(d->textureId, d->target, d->bindingTarget, 0x84FE, anisotropy); | - | ||||||||||||
3176 | } | - | ||||||||||||
3177 | - | |||||||||||||
3178 | - | |||||||||||||
3179 | - | |||||||||||||
3180 | - | |||||||||||||
3181 | - | |||||||||||||
3182 | - | |||||||||||||
3183 | - | |||||||||||||
3184 | float QOpenGLTexture::maximumAnisotropy() const | - | ||||||||||||
3185 | { | - | ||||||||||||
3186 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3187 | return d->maxAnisotropy; | - | ||||||||||||
3188 | } | - | ||||||||||||
3189 | - | |||||||||||||
3190 | - | |||||||||||||
3191 | - | |||||||||||||
3192 | - | |||||||||||||
3193 | - | |||||||||||||
3194 | - | |||||||||||||
3195 | void QOpenGLTexture::setWrapMode(QOpenGLTexture::WrapMode mode) | - | ||||||||||||
3196 | { | - | ||||||||||||
3197 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3198 | d->create(); | - | ||||||||||||
3199 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,40674076) : qt_noop()); | - | ||||||||||||
3200 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,40684077) : qt_noop()); | - | ||||||||||||
3201 | d->setWrapMode(mode); | - | ||||||||||||
3202 | } | - | ||||||||||||
3203 | - | |||||||||||||
3204 | - | |||||||||||||
3205 | - | |||||||||||||
3206 | - | |||||||||||||
3207 | - | |||||||||||||
3208 | void QOpenGLTexture::setWrapMode(QOpenGLTexture::CoordinateDirection direction, QOpenGLTexture::WrapMode mode) | - | ||||||||||||
3209 | { | - | ||||||||||||
3210 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3211 | d->create(); | - | ||||||||||||
3212 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,40804089) : qt_noop()); | - | ||||||||||||
3213 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,40814090) : qt_noop()); | - | ||||||||||||
3214 | d->setWrapMode(direction, mode); | - | ||||||||||||
3215 | } | - | ||||||||||||
3216 | - | |||||||||||||
3217 | - | |||||||||||||
3218 | - | |||||||||||||
3219 | - | |||||||||||||
3220 | - | |||||||||||||
3221 | - | |||||||||||||
3222 | QOpenGLTexture::WrapMode QOpenGLTexture::wrapMode(QOpenGLTexture::CoordinateDirection direction) const | - | ||||||||||||
3223 | { | - | ||||||||||||
3224 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3225 | return d->wrapMode(direction); | - | ||||||||||||
3226 | } | - | ||||||||||||
3227 | - | |||||||||||||
3228 | - | |||||||||||||
3229 | - | |||||||||||||
3230 | - | |||||||||||||
3231 | - | |||||||||||||
3232 | - | |||||||||||||
3233 | - | |||||||||||||
3234 | void QOpenGLTexture::setBorderColor(QColor color) | - | ||||||||||||
{ | ||||||||||||||
if (!QOpenGLContext::currentContext()->isOpenGLES()){ | ||||||||||||||
3236 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
d->create(); | ||||||||||||||
((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,4108) : qt_noop()); | ||||||||||||||
((!(d->textureId)) ? qt_assertsetBorderColor("d->textureId",__FILE__,4109) : qt_noop());static_cast<floatvalues[4]; | ||||||||||||||
values[0] =>(color.redF(); | ||||||||||||||
values[1] =()), static_cast<float>(color.greenF(); | ||||||||||||||
values[2] =()), | ||||||||||||||
3237 | static_cast<float>(color.blueF(); | - | ||||||||||||
values[3] =()), static_cast<float>(color.alphaF(); | ||||||||||||||
d->borderColor.clear(); | ||||||||||||||
for (int i = 0; i < 4; ++i) | ||||||||||||||
d->borderColor.append(QVariant(values[i])); | ||||||||||||||
d->texFuncs->glTextureParameterfv(d->textureId, d->target, d->bindingTarget, 0x1004, values); | ||||||||||||||
return; | ||||||||||||||
} | ||||||||||||||
QMessageLogger(__FILE__, 4124, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Border color is not supported");())); | ||||||||||||||
3238 | } never executed: end of block | 0 | ||||||||||||
3239 | - | |||||||||||||
3240 | - | |||||||||||||
3241 | - | |||||||||||||
3242 | - | |||||||||||||
3243 | - | |||||||||||||
3244 | - | |||||||||||||
3245 | void QOpenGLTexture::setBorderColor(float r, float g, float b, float a) | - | ||||||||||||
3246 | { | - | ||||||||||||
3247 | - | |||||||||||||
3248 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3249 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3250 | d->create(); | - | ||||||||||||
3251 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,41384128) : qt_noop()); | - | ||||||||||||
3252 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,41394129) : qt_noop()); | - | ||||||||||||
3253 | float values[4]; | - | ||||||||||||
3254 | values[0] = r; | - | ||||||||||||
3255 | values[1] = g; | - | ||||||||||||
3256 | values[2] = b; | - | ||||||||||||
3257 | values[3] = a; | - | ||||||||||||
3258 | d->borderColor.clear(); | - | ||||||||||||
3259 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3260 | d->borderColor.append(QVariant(values[i])); | - | ||||||||||||
3261 | d->texFuncs->glTextureParameterfv(d->textureId, d->target, d->bindingTarget, 0x1004, values); | - | ||||||||||||
3262 | return; | - | ||||||||||||
3263 | } | - | ||||||||||||
3264 | - | |||||||||||||
3265 | - | |||||||||||||
3266 | - | |||||||||||||
3267 | - | |||||||||||||
3268 | - | |||||||||||||
3269 | - | |||||||||||||
3270 | QMessageLogger(__FILE__, 41574147, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Border color is not supported"); | - | ||||||||||||
3271 | } | - | ||||||||||||
3272 | - | |||||||||||||
3273 | - | |||||||||||||
3274 | - | |||||||||||||
3275 | - | |||||||||||||
3276 | - | |||||||||||||
3277 | - | |||||||||||||
3278 | void QOpenGLTexture::setBorderColor(int r, int g, int b, int a) | - | ||||||||||||
3279 | { | - | ||||||||||||
3280 | - | |||||||||||||
3281 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3282 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3283 | d->create(); | - | ||||||||||||
3284 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,41714161) : qt_noop()); | - | ||||||||||||
3285 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,41724162) : qt_noop()); | - | ||||||||||||
3286 | int values[4]; | - | ||||||||||||
3287 | values[0] = r; | - | ||||||||||||
3288 | values[1] = g; | - | ||||||||||||
3289 | values[2] = b; | - | ||||||||||||
3290 | values[3] = a; | - | ||||||||||||
3291 | d->borderColor.clear(); | - | ||||||||||||
3292 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3293 | d->borderColor.append(QVariant(values[i])); | - | ||||||||||||
3294 | d->texFuncs->glTextureParameteriv(d->textureId, d->target, d->bindingTarget, 0x1004, values); | - | ||||||||||||
3295 | return; | - | ||||||||||||
3296 | } | - | ||||||||||||
3297 | - | |||||||||||||
3298 | - | |||||||||||||
3299 | - | |||||||||||||
3300 | - | |||||||||||||
3301 | - | |||||||||||||
3302 | - | |||||||||||||
3303 | QMessageLogger(__FILE__, 41904180, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Border color is not supported"); | - | ||||||||||||
3304 | - | |||||||||||||
3305 | - | |||||||||||||
3306 | } | - | ||||||||||||
3307 | - | |||||||||||||
3308 | - | |||||||||||||
3309 | - | |||||||||||||
3310 | - | |||||||||||||
3311 | - | |||||||||||||
3312 | - | |||||||||||||
3313 | void QOpenGLTexture::setBorderColor(uint r, uint g, uint b, uint a) | - | ||||||||||||
3314 | { | - | ||||||||||||
3315 | - | |||||||||||||
3316 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3317 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3318 | d->create(); | - | ||||||||||||
3319 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,42064196) : qt_noop()); | - | ||||||||||||
3320 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,42074197) : qt_noop()); | - | ||||||||||||
3321 | int values[4]; | - | ||||||||||||
3322 | values[0] = int(r); | - | ||||||||||||
3323 | values[1] = int(g); | - | ||||||||||||
3324 | values[2] = int(b); | - | ||||||||||||
3325 | values[3] = int(a); | - | ||||||||||||
3326 | d->borderColor.clear(); | - | ||||||||||||
3327 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3328 | d->borderColor.append(QVariant(values[i])); | - | ||||||||||||
3329 | d->texFuncs->glTextureParameteriv(d->textureId, d->target, d->bindingTarget, 0x1004, values); | - | ||||||||||||
3330 | return; | - | ||||||||||||
3331 | } | - | ||||||||||||
3332 | - | |||||||||||||
3333 | - | |||||||||||||
3334 | - | |||||||||||||
3335 | - | |||||||||||||
3336 | - | |||||||||||||
3337 | - | |||||||||||||
3338 | QMessageLogger(__FILE__, 42254215, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Border color is not supported"); | - | ||||||||||||
3339 | - | |||||||||||||
3340 | - | |||||||||||||
3341 | } | - | ||||||||||||
3342 | - | |||||||||||||
3343 | - | |||||||||||||
3344 | - | |||||||||||||
3345 | - | |||||||||||||
3346 | - | |||||||||||||
3347 | - | |||||||||||||
3348 | QColor QOpenGLTexture::borderColor() const | - | ||||||||||||
3349 | { | - | ||||||||||||
3350 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3351 | QColor c(0.0f, 0.0f, 0.0f, 0.0f); | - | ||||||||||||
3352 | if (!d->borderColor.isEmpty()) { | - | ||||||||||||
3353 | c.setRedF(d->borderColor.at(0).toFloat()); | - | ||||||||||||
3354 | c.setGreenF(d->borderColor.at(1).toFloat()); | - | ||||||||||||
3355 | c.setBlueF(d->borderColor.at(2).toFloat()); | - | ||||||||||||
3356 | c.setAlphaF(d->borderColor.at(3).toFloat()); | - | ||||||||||||
3357 | } | - | ||||||||||||
3358 | return c; | - | ||||||||||||
3359 | } | - | ||||||||||||
3360 | - | |||||||||||||
3361 | - | |||||||||||||
3362 | - | |||||||||||||
3363 | - | |||||||||||||
3364 | - | |||||||||||||
3365 | - | |||||||||||||
3366 | - | |||||||||||||
3367 | void QOpenGLTexture::borderColor(float *border) const | - | ||||||||||||
3368 | { | - | ||||||||||||
3369 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3370 | ((!(border)) ? qt_assert("border",__FILE__,42574247) : qt_noop()); | - | ||||||||||||
3371 | if (d->borderColor.isEmpty()) { | - | ||||||||||||
3372 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3373 | border[i] = 0.0f; | - | ||||||||||||
3374 | } else { | - | ||||||||||||
3375 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3376 | border[i] = d->borderColor.at(i).toFloat(); | - | ||||||||||||
3377 | } | - | ||||||||||||
3378 | } | - | ||||||||||||
3379 | - | |||||||||||||
3380 | - | |||||||||||||
3381 | - | |||||||||||||
3382 | - | |||||||||||||
3383 | - | |||||||||||||
3384 | - | |||||||||||||
3385 | - | |||||||||||||
3386 | void QOpenGLTexture::borderColor(int *border) const | - | ||||||||||||
3387 | { | - | ||||||||||||
3388 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3389 | ((!(border)) ? qt_assert("border",__FILE__,42764266) : qt_noop()); | - | ||||||||||||
3390 | if (d->borderColor.isEmpty()) { | - | ||||||||||||
3391 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3392 | border[i] = 0; | - | ||||||||||||
3393 | } else { | - | ||||||||||||
3394 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3395 | border[i] = d->borderColor.at(i).toInt(); | - | ||||||||||||
3396 | } | - | ||||||||||||
3397 | } | - | ||||||||||||
3398 | - | |||||||||||||
3399 | - | |||||||||||||
3400 | - | |||||||||||||
3401 | - | |||||||||||||
3402 | - | |||||||||||||
3403 | - | |||||||||||||
3404 | - | |||||||||||||
3405 | void QOpenGLTexture::borderColor(unsigned int *border) const | - | ||||||||||||
3406 | { | - | ||||||||||||
3407 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3408 | ((!(border)) ? qt_assert("border",__FILE__,42954285) : qt_noop()); | - | ||||||||||||
3409 | if (d->borderColor.isEmpty()) { | - | ||||||||||||
3410 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3411 | border[i] = 0; | - | ||||||||||||
3412 | } else { | - | ||||||||||||
3413 | for (int i = 0; i < 4; ++i) | - | ||||||||||||
3414 | border[i] = d->borderColor.at(i).toUInt(); | - | ||||||||||||
3415 | } | - | ||||||||||||
3416 | } | - | ||||||||||||
3417 | void QOpenGLTexture::setMinimumLevelOfDetail(float value) | - | ||||||||||||
3418 | { | - | ||||||||||||
3419 | - | |||||||||||||
3420 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3421 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3422 | d->create(); | - | ||||||||||||
3423 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,43184308) : qt_noop()); | - | ||||||||||||
3424 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,43194309) : qt_noop()); | - | ||||||||||||
3425 | ((!(value < d->maxLevelOfDetail)) ? qt_assert("value < d->maxLevelOfDetail",__FILE__,43204310) : qt_noop()); | - | ||||||||||||
3426 | d->minLevelOfDetail = value; | - | ||||||||||||
3427 | d->texFuncs->glTextureParameterf(d->textureId, d->target, d->bindingTarget, 0x813A, value); | - | ||||||||||||
3428 | return; | - | ||||||||||||
3429 | } | - | ||||||||||||
3430 | - | |||||||||||||
3431 | - | |||||||||||||
3432 | - | |||||||||||||
3433 | QMessageLogger(__FILE__, 43284318, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Detail level is not supported"); | - | ||||||||||||
3434 | } | - | ||||||||||||
3435 | - | |||||||||||||
3436 | - | |||||||||||||
3437 | - | |||||||||||||
3438 | - | |||||||||||||
3439 | - | |||||||||||||
3440 | - | |||||||||||||
3441 | float QOpenGLTexture::minimumLevelOfDetail() const | - | ||||||||||||
3442 | { | - | ||||||||||||
3443 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3444 | return d->minLevelOfDetail; | - | ||||||||||||
3445 | } | - | ||||||||||||
3446 | void QOpenGLTexture::setMaximumLevelOfDetail(float value) | - | ||||||||||||
3447 | { | - | ||||||||||||
3448 | - | |||||||||||||
3449 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3450 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3451 | d->create(); | - | ||||||||||||
3452 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,43554345) : qt_noop()); | - | ||||||||||||
3453 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,43564346) : qt_noop()); | - | ||||||||||||
3454 | ((!(value > d->minLevelOfDetail)) ? qt_assert("value > d->minLevelOfDetail",__FILE__,43574347) : qt_noop()); | - | ||||||||||||
3455 | d->maxLevelOfDetail = value; | - | ||||||||||||
3456 | d->texFuncs->glTextureParameterf(d->textureId, d->target, d->bindingTarget, 0x813B, value); | - | ||||||||||||
3457 | return; | - | ||||||||||||
3458 | } | - | ||||||||||||
3459 | - | |||||||||||||
3460 | - | |||||||||||||
3461 | - | |||||||||||||
3462 | QMessageLogger(__FILE__, 43654355, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Detail level is not supported"); | - | ||||||||||||
3463 | } | - | ||||||||||||
3464 | - | |||||||||||||
3465 | - | |||||||||||||
3466 | - | |||||||||||||
3467 | - | |||||||||||||
3468 | - | |||||||||||||
3469 | - | |||||||||||||
3470 | float QOpenGLTexture::maximumLevelOfDetail() const | - | ||||||||||||
3471 | { | - | ||||||||||||
3472 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3473 | return d->maxLevelOfDetail; | - | ||||||||||||
3474 | } | - | ||||||||||||
3475 | - | |||||||||||||
3476 | - | |||||||||||||
3477 | - | |||||||||||||
3478 | - | |||||||||||||
3479 | - | |||||||||||||
3480 | - | |||||||||||||
3481 | - | |||||||||||||
3482 | void QOpenGLTexture::setLevelOfDetailRange(float min, float max) | - | ||||||||||||
3483 | { | - | ||||||||||||
3484 | - | |||||||||||||
3485 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3486 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3487 | d->create(); | - | ||||||||||||
3488 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,43914381) : qt_noop()); | - | ||||||||||||
3489 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,43924382) : qt_noop()); | - | ||||||||||||
3490 | ((!(min < max)) ? qt_assert("min < max",__FILE__,43934383) : qt_noop()); | - | ||||||||||||
3491 | d->minLevelOfDetail = min; | - | ||||||||||||
3492 | d->maxLevelOfDetail = max; | - | ||||||||||||
3493 | d->texFuncs->glTextureParameterf(d->textureId, d->target, d->bindingTarget, 0x813A, min); | - | ||||||||||||
3494 | d->texFuncs->glTextureParameterf(d->textureId, d->target, d->bindingTarget, 0x813B, max); | - | ||||||||||||
3495 | return; | - | ||||||||||||
3496 | } | - | ||||||||||||
3497 | - | |||||||||||||
3498 | - | |||||||||||||
3499 | - | |||||||||||||
3500 | - | |||||||||||||
3501 | QMessageLogger(__FILE__, 44044394, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Detail level is not supported"); | - | ||||||||||||
3502 | } | - | ||||||||||||
3503 | - | |||||||||||||
3504 | - | |||||||||||||
3505 | - | |||||||||||||
3506 | - | |||||||||||||
3507 | - | |||||||||||||
3508 | - | |||||||||||||
3509 | QPair<float, float> QOpenGLTexture::levelOfDetailRange() const | - | ||||||||||||
3510 | { | - | ||||||||||||
3511 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3512 | return qMakePair(d->minLevelOfDetail, d->maxLevelOfDetail); | - | ||||||||||||
3513 | } | - | ||||||||||||
3514 | void QOpenGLTexture::setLevelofDetailBias(float bias) | - | ||||||||||||
3515 | { | - | ||||||||||||
3516 | - | |||||||||||||
3517 | if (!QOpenGLContext::currentContext()->isOpenGLES()) { | - | ||||||||||||
3518 | QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3519 | d->create(); | - | ||||||||||||
3520 | ((!(d->texFuncs)) ? qt_assert("d->texFuncs",__FILE__,44334423) : qt_noop()); | - | ||||||||||||
3521 | ((!(d->textureId)) ? qt_assert("d->textureId",__FILE__,44344424) : qt_noop()); | - | ||||||||||||
3522 | d->levelOfDetailBias = bias; | - | ||||||||||||
3523 | d->texFuncs->glTextureParameterf(d->textureId, d->target, d->bindingTarget, 0x8501, bias); | - | ||||||||||||
3524 | return; | - | ||||||||||||
3525 | } | - | ||||||||||||
3526 | - | |||||||||||||
3527 | - | |||||||||||||
3528 | - | |||||||||||||
3529 | QMessageLogger(__FILE__, 44424432, __PRETTY_FUNCTION__).warning("QOpenGLTexture: Detail level is not supported"); | - | ||||||||||||
3530 | } | - | ||||||||||||
3531 | - | |||||||||||||
3532 | - | |||||||||||||
3533 | - | |||||||||||||
3534 | - | |||||||||||||
3535 | - | |||||||||||||
3536 | - | |||||||||||||
3537 | float QOpenGLTexture::levelofDetailBias() const | - | ||||||||||||
3538 | { | - | ||||||||||||
3539 | const QOpenGLTexturePrivate * const d = d_func(); | - | ||||||||||||
3540 | return d->levelOfDetailBias; | - | ||||||||||||
3541 | } | - | ||||||||||||
3542 | - | |||||||||||||
3543 | - | |||||||||||||
Switch to Source code | Preprocessed file |