1/****************************************************************************
2**
3** Copyright (C) 2013 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QOPENGLABSTRACTTEXTURE_H
41#define QOPENGLABSTRACTTEXTURE_H
42
43#include <QtGui/qtguiglobal.h>
44
45#ifndef QT_NO_OPENGL
46
47#include <QtGui/qopengl.h>
48#include <QtGui/qimage.h>
49#include <QtCore/QScopedPointer>
50
51QT_BEGIN_NAMESPACE
52
53class QDebug;
54class QOpenGLTexturePrivate;
55class QOpenGLPixelTransferOptions;
56
57class Q_GUI_EXPORT QOpenGLTexture
58{
59 Q_GADGET
60public:
61 enum Target {
62 Target1D = 0x0DE0, // GL_TEXTURE_1D
63 Target1DArray = 0x8C18, // GL_TEXTURE_1D_ARRAY
64 Target2D = 0x0DE1, // GL_TEXTURE_2D
65 Target2DArray = 0x8C1A, // GL_TEXTURE_2D_ARRAY
66 Target3D = 0x806F, // GL_TEXTURE_3D
67 TargetCubeMap = 0x8513, // GL_TEXTURE_CUBE_MAP
68 TargetCubeMapArray = 0x9009, // GL_TEXTURE_CUBE_MAP_ARRAY
69 Target2DMultisample = 0x9100, // GL_TEXTURE_2D_MULTISAMPLE
70 Target2DMultisampleArray = 0x9102, // GL_TEXTURE_2D_MULTISAMPLE_ARRAY
71 TargetRectangle = 0x84F5, // GL_TEXTURE_RECTANGLE
72 TargetBuffer = 0x8C2A // GL_TEXTURE_BUFFER
73 };
74 Q_ENUM(Target)
75
76 enum BindingTarget {
77 BindingTarget1D = 0x8068, // GL_TEXTURE_BINDING_1D
78 BindingTarget1DArray = 0x8C1C, // GL_TEXTURE_BINDING_1D_ARRAY
79 BindingTarget2D = 0x8069, // GL_TEXTURE_BINDING_2D
80 BindingTarget2DArray = 0x8C1D, // GL_TEXTURE_BINDING_2D_ARRAY
81 BindingTarget3D = 0x806A, // GL_TEXTURE_BINDING_3D
82 BindingTargetCubeMap = 0x8514, // GL_TEXTURE_BINDING_CUBE_MAP
83 BindingTargetCubeMapArray = 0x900A, // GL_TEXTURE_BINDING_CUBE_MAP_ARRAY
84 BindingTarget2DMultisample = 0x9104, // GL_TEXTURE_BINDING_2D_MULTISAMPLE
85 BindingTarget2DMultisampleArray = 0x9105, // GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY
86 BindingTargetRectangle = 0x84F6, // GL_TEXTURE_BINDING_RECTANGLE
87 BindingTargetBuffer = 0x8C2C // GL_TEXTURE_BINDING_BUFFER
88 };
89 Q_ENUM(BindingTarget)
90
91 enum MipMapGeneration {
92 GenerateMipMaps,
93 DontGenerateMipMaps
94 };
95 Q_ENUM(MipMapGeneration)
96
97 enum TextureUnitReset {
98 ResetTextureUnit,
99 DontResetTextureUnit
100 };
101 Q_ENUM(TextureUnitReset)
102
103 enum TextureFormat {
104 NoFormat = 0, // GL_NONE
105
106 // Unsigned normalized formats
107 R8_UNorm = 0x8229, // GL_R8
108 RG8_UNorm = 0x822B, // GL_RG8
109 RGB8_UNorm = 0x8051, // GL_RGB8
110 RGBA8_UNorm = 0x8058, // GL_RGBA8
111
112 R16_UNorm = 0x822A, // GL_R16
113 RG16_UNorm = 0x822C, // GL_RG16
114 RGB16_UNorm = 0x8054, // GL_RGB16
115 RGBA16_UNorm = 0x805B, // GL_RGBA16
116
117 // Signed normalized formats
118 R8_SNorm = 0x8F94, // GL_R8_SNORM
119 RG8_SNorm = 0x8F95, // GL_RG8_SNORM
120 RGB8_SNorm = 0x8F96, // GL_RGB8_SNORM
121 RGBA8_SNorm = 0x8F97, // GL_RGBA8_SNORM
122
123 R16_SNorm = 0x8F98, // GL_R16_SNORM
124 RG16_SNorm = 0x8F99, // GL_RG16_SNORM
125 RGB16_SNorm = 0x8F9A, // GL_RGB16_SNORM
126 RGBA16_SNorm = 0x8F9B, // GL_RGBA16_SNORM
127
128 // Unsigned integer formats
129 R8U = 0x8232, // GL_R8UI
130 RG8U = 0x8238, // GL_RG8UI
131 RGB8U = 0x8D7D, // GL_RGB8UI
132 RGBA8U = 0x8D7C, // GL_RGBA8UI
133
134 R16U = 0x8234, // GL_R16UI
135 RG16U = 0x823A, // GL_RG16UI
136 RGB16U = 0x8D77, // GL_RGB16UI
137 RGBA16U = 0x8D76, // GL_RGBA16UI
138
139 R32U = 0x8236, // GL_R32UI
140 RG32U = 0x823C, // GL_RG32UI
141 RGB32U = 0x8D71, // GL_RGB32UI
142 RGBA32U = 0x8D70, // GL_RGBA32UI
143
144 // Signed integer formats
145 R8I = 0x8231, // GL_R8I
146 RG8I = 0x8237, // GL_RG8I
147 RGB8I = 0x8D8F, // GL_RGB8I
148 RGBA8I = 0x8D8E, // GL_RGBA8I
149
150 R16I = 0x8233, // GL_R16I
151 RG16I = 0x8239, // GL_RG16I
152 RGB16I = 0x8D89, // GL_RGB16I
153 RGBA16I = 0x8D88, // GL_RGBA16I
154
155 R32I = 0x8235, // GL_R32I
156 RG32I = 0x823B, // GL_RG32I
157 RGB32I = 0x8D83, // GL_RGB32I
158 RGBA32I = 0x8D82, // GL_RGBA32I
159
160 // Floating point formats
161 R16F = 0x822D, // GL_R16F
162 RG16F = 0x822F, // GL_RG16F
163 RGB16F = 0x881B, // GL_RGB16F
164 RGBA16F = 0x881A, // GL_RGBA16F
165
166 R32F = 0x822E, // GL_R32F
167 RG32F = 0x8230, // GL_RG32F
168 RGB32F = 0x8815, // GL_RGB32F
169 RGBA32F = 0x8814, // GL_RGBA32F
170
171 // Packed formats
172 RGB9E5 = 0x8C3D, // GL_RGB9_E5
173 RG11B10F = 0x8C3A, // GL_R11F_G11F_B10F
174 RG3B2 = 0x2A10, // GL_R3_G3_B2
175 R5G6B5 = 0x8D62, // GL_RGB565
176 RGB5A1 = 0x8057, // GL_RGB5_A1
177 RGBA4 = 0x8056, // GL_RGBA4
178 RGB10A2 = 0x906F, // GL_RGB10_A2UI
179
180 // Depth formats
181 D16 = 0x81A5, // GL_DEPTH_COMPONENT16
182 D24 = 0x81A6, // GL_DEPTH_COMPONENT24
183 D24S8 = 0x88F0, // GL_DEPTH24_STENCIL8
184 D32 = 0x81A7, // GL_DEPTH_COMPONENT32
185 D32F = 0x8CAC, // GL_DEPTH_COMPONENT32F
186 D32FS8X24 = 0x8CAD, // GL_DEPTH32F_STENCIL8
187 S8 = 0x8D48, // GL_STENCIL_INDEX8
188
189 // Compressed formats
190 RGB_DXT1 = 0x83F0, // GL_COMPRESSED_RGB_S3TC_DXT1_EXT
191 RGBA_DXT1 = 0x83F1, // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
192 RGBA_DXT3 = 0x83F2, // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
193 RGBA_DXT5 = 0x83F3, // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
194 R_ATI1N_UNorm = 0x8DBB, // GL_COMPRESSED_RED_RGTC1
195 R_ATI1N_SNorm = 0x8DBC, // GL_COMPRESSED_SIGNED_RED_RGTC1
196 RG_ATI2N_UNorm = 0x8DBD, // GL_COMPRESSED_RG_RGTC2
197 RG_ATI2N_SNorm = 0x8DBE, // GL_COMPRESSED_SIGNED_RG_RGTC2
198 RGB_BP_UNSIGNED_FLOAT = 0x8E8F, // GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB
199 RGB_BP_SIGNED_FLOAT = 0x8E8E, // GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB
200 RGB_BP_UNorm = 0x8E8C, // GL_COMPRESSED_RGBA_BPTC_UNORM_ARB
201 R11_EAC_UNorm = 0x9270, // GL_COMPRESSED_R11_EAC
202 R11_EAC_SNorm = 0x9271, // GL_COMPRESSED_SIGNED_R11_EAC
203 RG11_EAC_UNorm = 0x9272, // GL_COMPRESSED_RG11_EAC
204 RG11_EAC_SNorm = 0x9273, // GL_COMPRESSED_SIGNED_RG11_EAC
205 RGB8_ETC2 = 0x9274, // GL_COMPRESSED_RGB8_ETC2
206 SRGB8_ETC2 = 0x9275, // GL_COMPRESSED_SRGB8_ETC2
207 RGB8_PunchThrough_Alpha1_ETC2 = 0x9276, // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
208 SRGB8_PunchThrough_Alpha1_ETC2 = 0x9277, // GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2
209 RGBA8_ETC2_EAC = 0x9278, // GL_COMPRESSED_RGBA8_ETC2_EAC
210 SRGB8_Alpha8_ETC2_EAC = 0x9279, // GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC
211 RGB8_ETC1 = 0x8D64, // GL_ETC1_RGB8_OES
212 RGBA_ASTC_4x4 = 0x93B0, // GL_COMPRESSED_RGBA_ASTC_4x4_KHR
213 RGBA_ASTC_5x4 = 0x93B1, // GL_COMPRESSED_RGBA_ASTC_5x4_KHR
214 RGBA_ASTC_5x5 = 0x93B2, // GL_COMPRESSED_RGBA_ASTC_5x5_KHR
215 RGBA_ASTC_6x5 = 0x93B3, // GL_COMPRESSED_RGBA_ASTC_6x5_KHR
216 RGBA_ASTC_6x6 = 0x93B4, // GL_COMPRESSED_RGBA_ASTC_6x6_KHR
217 RGBA_ASTC_8x5 = 0x93B5, // GL_COMPRESSED_RGBA_ASTC_8x5_KHR
218 RGBA_ASTC_8x6 = 0x93B6, // GL_COMPRESSED_RGBA_ASTC_8x6_KHR
219 RGBA_ASTC_8x8 = 0x93B7, // GL_COMPRESSED_RGBA_ASTC_8x8_KHR
220 RGBA_ASTC_10x5 = 0x93B8, // GL_COMPRESSED_RGBA_ASTC_10x5_KHR
221 RGBA_ASTC_10x6 = 0x93B9, // GL_COMPRESSED_RGBA_ASTC_10x6_KHR
222 RGBA_ASTC_10x8 = 0x93BA, // GL_COMPRESSED_RGBA_ASTC_10x8_KHR
223 RGBA_ASTC_10x10 = 0x93BB, // GL_COMPRESSED_RGBA_ASTC_10x10_KHR
224 RGBA_ASTC_12x10 = 0x93BC, // GL_COMPRESSED_RGBA_ASTC_12x10_KHR
225 RGBA_ASTC_12x12 = 0x93BD, // GL_COMPRESSED_RGBA_ASTC_12x12_KHR
226 SRGB8_Alpha8_ASTC_4x4 = 0x93D0, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR
227 SRGB8_Alpha8_ASTC_5x4 = 0x93D1, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR
228 SRGB8_Alpha8_ASTC_5x5 = 0x93D2, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR
229 SRGB8_Alpha8_ASTC_6x5 = 0x93D3, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR
230 SRGB8_Alpha8_ASTC_6x6 = 0x93D4, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR
231 SRGB8_Alpha8_ASTC_8x5 = 0x93D5, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR
232 SRGB8_Alpha8_ASTC_8x6 = 0x93D6, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR
233 SRGB8_Alpha8_ASTC_8x8 = 0x93D7, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR
234 SRGB8_Alpha8_ASTC_10x5 = 0x93D8, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR
235 SRGB8_Alpha8_ASTC_10x6 = 0x93D9, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR
236 SRGB8_Alpha8_ASTC_10x8 = 0x93DA, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR
237 SRGB8_Alpha8_ASTC_10x10 = 0x93DB, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR
238 SRGB8_Alpha8_ASTC_12x10 = 0x93DC, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR
239 SRGB8_Alpha8_ASTC_12x12 = 0x93DD, // GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR
240
241 // sRGB formats
242 SRGB8 = 0x8C41, // GL_SRGB8
243 SRGB8_Alpha8 = 0x8C43, // GL_SRGB8_ALPHA8
244 SRGB_DXT1 = 0x8C4C, // GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
245 SRGB_Alpha_DXT1 = 0x8C4D, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
246 SRGB_Alpha_DXT3 = 0x8C4E, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
247 SRGB_Alpha_DXT5 = 0x8C4F, // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
248 SRGB_BP_UNorm = 0x8E8D, // GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB
249
250 // ES 2 formats
251 DepthFormat = 0x1902, // GL_DEPTH_COMPONENT
252 AlphaFormat = 0x1906, // GL_ALPHA
253 RGBFormat = 0x1907, // GL_RGB
254 RGBAFormat = 0x1908, // GL_RGBA
255 LuminanceFormat = 0x1909, // GL_LUMINANCE
256 LuminanceAlphaFormat = 0x190A
257
258 };
259 Q_ENUM(TextureFormat)
260
261 // This is not used externally yet but is reserved to allow checking of
262 // compatibility between texture formats
263#ifndef Q_QDOC
264 enum TextureFormatClass {
265 NoFormatClass,
266 FormatClass_128Bit,
267 FormatClass_96Bit,
268 FormatClass_64Bit,
269 FormatClass_48Bit,
270 FormatClass_32Bit,
271 FormatClass_24Bit,
272 FormatClass_16Bit,
273 FormatClass_8Bit,
274 FormatClass_RGTC1_R,
275 FormatClass_RGTC2_RG,
276 FormatClass_BPTC_Unorm,
277 FormatClass_BPTC_Float,
278 FormatClass_S3TC_DXT1_RGB,
279 FormatClass_S3TC_DXT1_RGBA,
280 FormatClass_S3TC_DXT3_RGBA,
281 FormatClass_S3TC_DXT5_RGBA,
282 FormatClass_Unique
283 };
284#endif
285
286 enum CubeMapFace {
287 CubeMapPositiveX = 0x8515, // GL_TEXTURE_CUBE_MAP_POSITIVE_X
288 CubeMapNegativeX = 0x8516, // GL_TEXTURE_CUBE_MAP_NEGATIVE_X
289 CubeMapPositiveY = 0x8517, // GL_TEXTURE_CUBE_MAP_POSITIVE_Y
290 CubeMapNegativeY = 0x8518, // GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
291 CubeMapPositiveZ = 0x8519, // GL_TEXTURE_CUBE_MAP_POSITIVE_Z
292 CubeMapNegativeZ = 0x851A // GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
293 };
294 Q_ENUM(CubeMapFace)
295
296 enum PixelFormat {
297 NoSourceFormat = 0, // GL_NONE
298 Red = 0x1903, // GL_RED
299 RG = 0x8227, // GL_RG
300 RGB = 0x1907, // GL_RGB
301 BGR = 0x80E0, // GL_BGR
302 RGBA = 0x1908, // GL_RGBA
303 BGRA = 0x80E1, // GL_BGRA
304 Red_Integer = 0x8D94, // GL_RED_INTEGER
305 RG_Integer = 0x8228, // GL_RG_INTEGER
306 RGB_Integer = 0x8D98, // GL_RGB_INTEGER
307 BGR_Integer = 0x8D9A, // GL_BGR_INTEGER
308 RGBA_Integer = 0x8D99, // GL_RGBA_INTEGER
309 BGRA_Integer = 0x8D9B, // GL_BGRA_INTEGER
310 Stencil = 0x1901, // GL_STENCIL_INDEX
311 Depth = 0x1902, // GL_DEPTH_COMPONENT
312 DepthStencil = 0x84F9, // GL_DEPTH_STENCIL
313 Alpha = 0x1906, // GL_ALPHA
314 Luminance = 0x1909, // GL_LUMINANCE
315 LuminanceAlpha = 0x190A // GL_LUMINANCE_ALPHA
316 };
317 Q_ENUM(PixelFormat)
318
319 enum PixelType {
320 NoPixelType = 0, // GL_NONE
321 Int8 = 0x1400, // GL_BYTE
322 UInt8 = 0x1401, // GL_UNSIGNED_BYTE
323 Int16 = 0x1402, // GL_SHORT
324 UInt16 = 0x1403, // GL_UNSIGNED_SHORT
325 Int32 = 0x1404, // GL_INT
326 UInt32 = 0x1405, // GL_UNSIGNED_INT
327 Float16 = 0x140B, // GL_HALF_FLOAT
328 Float16OES = 0x8D61, // GL_HALF_FLOAT_OES
329 Float32 = 0x1406, // GL_FLOAT
330 UInt32_RGB9_E5 = 0x8C3E, // GL_UNSIGNED_INT_5_9_9_9_REV
331 UInt32_RG11B10F = 0x8C3B, // GL_UNSIGNED_INT_10F_11F_11F_REV
332 UInt8_RG3B2 = 0x8032, // GL_UNSIGNED_BYTE_3_3_2
333 UInt8_RG3B2_Rev = 0x8362, // GL_UNSIGNED_BYTE_2_3_3_REV
334 UInt16_RGB5A1 = 0x8034, // GL_UNSIGNED_SHORT_5_5_5_1
335 UInt16_RGB5A1_Rev = 0x8366, // GL_UNSIGNED_SHORT_1_5_5_5_REV
336 UInt16_R5G6B5 = 0x8363, // GL_UNSIGNED_SHORT_5_6_5
337 UInt16_R5G6B5_Rev = 0x8364, // GL_UNSIGNED_SHORT_5_6_5_REV
338 UInt16_RGBA4 = 0x8033, // GL_UNSIGNED_SHORT_4_4_4_4
339 UInt16_RGBA4_Rev = 0x8365, // GL_UNSIGNED_SHORT_4_4_4_4_REV
340 UInt32_RGBA8 = 0x8035, // GL_UNSIGNED_INT_8_8_8_8
341 UInt32_RGBA8_Rev = 0x8367, // GL_UNSIGNED_INT_8_8_8_8_REV
342 UInt32_RGB10A2 = 0x8036, // GL_UNSIGNED_INT_10_10_10_2
343 UInt32_RGB10A2_Rev = 0x8368, // GL_UNSIGNED_INT_2_10_10_10_REV
344 UInt32_D24S8 = 0x84FA, // GL_UNSIGNED_INT_24_8
345 Float32_D32_UInt32_S8_X24 = 0x8DAD // GL_FLOAT_32_UNSIGNED_INT_24_8_REV
346 };
347 Q_ENUM(PixelType)
348
349 enum SwizzleComponent {
350 SwizzleRed = 0x8E42, // GL_TEXTURE_SWIZZLE_R
351 SwizzleGreen = 0x8E43, // GL_TEXTURE_SWIZZLE_G
352 SwizzleBlue = 0x8E44, // GL_TEXTURE_SWIZZLE_B
353 SwizzleAlpha = 0x8E45 // GL_TEXTURE_SWIZZLE_A
354 };
355 Q_ENUM(SwizzleComponent)
356
357 enum SwizzleValue {
358 RedValue = 0x1903, // GL_RED
359 GreenValue = 0x1904, // GL_GREEN
360 BlueValue = 0x1905, // GL_BLUE
361 AlphaValue = 0x1906, // GL_ALPHA
362 ZeroValue = 0, // GL_ZERO
363 OneValue = 1 // GL_ONE
364 };
365 Q_ENUM(SwizzleValue)
366
367 enum WrapMode {
368 Repeat = 0x2901, // GL_REPEAT
369 MirroredRepeat = 0x8370, // GL_MIRRORED_REPEAT
370 ClampToEdge = 0x812F, // GL_CLAMP_TO_EDGE
371 ClampToBorder = 0x812D // GL_CLAMP_TO_BORDER
372 };
373 Q_ENUM(WrapMode)
374
375 enum CoordinateDirection {
376 DirectionS = 0x2802, // GL_TEXTURE_WRAP_S
377 DirectionT = 0x2803, // GL_TEXTURE_WRAP_T
378 DirectionR = 0x8072 // GL_TEXTURE_WRAP_R
379 };
380 Q_ENUM(CoordinateDirection)
381
382 // Features
383 enum Feature {
384 ImmutableStorage = 0x00000001,
385 ImmutableMultisampleStorage = 0x00000002,
386 TextureRectangle = 0x00000004,
387 TextureArrays = 0x00000008,
388 Texture3D = 0x00000010,
389 TextureMultisample = 0x00000020,
390 TextureBuffer = 0x00000040,
391 TextureCubeMapArrays = 0x00000080,
392 Swizzle = 0x00000100,
393 StencilTexturing = 0x00000200,
394 AnisotropicFiltering = 0x00000400,
395 NPOTTextures = 0x00000800,
396 NPOTTextureRepeat = 0x00001000,
397 Texture1D = 0x00002000,
398 TextureComparisonOperators = 0x00004000,
399 TextureMipMapLevel = 0x00008000,
400#ifndef Q_QDOC
401 MaxFeatureFlag = 0x00010000
402#endif
403 };
404 Q_DECLARE_FLAGS(Features, Feature)
405 Q_ENUM(Feature)
406
407 explicit QOpenGLTexture(Target target);
408 explicit QOpenGLTexture(const QImage& image, MipMapGeneration genMipMaps = GenerateMipMaps);
409 ~QOpenGLTexture();
410
411 Target target() const;
412
413 // Creation and destruction
414 bool create();
415 void destroy();
416 bool isCreated() const;
417 GLuint textureId() const;
418
419 // Binding and releasing
420 void bind();
421 void bind(uint unit, TextureUnitReset reset = DontResetTextureUnit);
422 void release();
423 void release(uint unit, TextureUnitReset reset = DontResetTextureUnit);
424
425 bool isBound() const;
426 bool isBound(uint unit);
427 static GLuint boundTextureId(BindingTarget target);
428 static GLuint boundTextureId(uint unit, BindingTarget target);
429
430 // Storage allocation
431 void setFormat(TextureFormat format);
432 TextureFormat format() const;
433 void setSize(int width, int height = 1, int depth = 1);
434 int width() const;
435 int height() const;
436 int depth() const;
437 void setMipLevels(int levels);
438 int mipLevels() const;
439 int maximumMipLevels() const;
440 void setLayers(int layers);
441 int layers() const;
442 int faces() const;
443 void setSamples(int samples);
444 int samples() const;
445 void setFixedSamplePositions(bool fixed);
446 bool isFixedSamplePositions() const;
447 void allocateStorage();
448 void allocateStorage(PixelFormat pixelFormat, PixelType pixelType);
449 bool isStorageAllocated() const;
450
451 QOpenGLTexture *createTextureView(Target target,
452 TextureFormat viewFormat,
453 int minimumMipmapLevel, int maximumMipmapLevel,
454 int minimumLayer, int maximumLayer) const;
455 bool isTextureView() const;
456
457 // Pixel transfer
458 // ### Qt 6: remove the non-const void * overloads
459#if QT_DEPRECATED_SINCE(5, 3)
460 QT_DEPRECATED void setData(int mipLevel, int layer, CubeMapFace cubeFace,
461 PixelFormat sourceFormat, PixelType sourceType,
462 void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
463 QT_DEPRECATED void setData(int mipLevel, int layer,
464 PixelFormat sourceFormat, PixelType sourceType,
465 void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
466 QT_DEPRECATED void setData(int mipLevel,
467 PixelFormat sourceFormat, PixelType sourceType,
468 void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
469 QT_DEPRECATED void setData(PixelFormat sourceFormat, PixelType sourceType,
470 void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
471#endif // QT_DEPRECATED_SINCE(5, 3)
472
473 void setData(int mipLevel, int layer, CubeMapFace cubeFace,
474 PixelFormat sourceFormat, PixelType sourceType,
475 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
476 void setData(int mipLevel, int layer, int layerCount, CubeMapFace cubeFace,
477 PixelFormat sourceFormat, PixelType sourceType,
478 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
479 void setData(int mipLevel, int layer,
480 PixelFormat sourceFormat, PixelType sourceType,
481 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
482 void setData(int mipLevel,
483 PixelFormat sourceFormat, PixelType sourceType,
484 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
485 void setData(PixelFormat sourceFormat, PixelType sourceType,
486 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
487
488 void setData(int xOffset, int yOffset, int zOffset,
489 int width, int height, int depth,
490 PixelFormat sourceFormat, PixelType sourceType,
491 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
492 void setData(int xOffset, int yOffset, int zOffset,
493 int width, int height, int depth, int mipLevel,
494 PixelFormat sourceFormat, PixelType sourceType,
495 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
496 void setData(int xOffset, int yOffset, int zOffset,
497 int width, int height, int depth,
498 int mipLevel, int layer,
499 PixelFormat sourceFormat, PixelType sourceType,
500 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
501 void setData(int xOffset, int yOffset, int zOffset,
502 int width, int height, int depth,
503 int mipLevel, int layer,
504 CubeMapFace cubeFace,
505 PixelFormat sourceFormat, PixelType sourceType,
506 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
507 void setData(int xOffset, int yOffset, int zOffset,
508 int width, int height, int depth,
509 int mipLevel, int layer,
510 CubeMapFace cubeFace, int layerCount,
511 PixelFormat sourceFormat, PixelType sourceType,
512 const void *data, const QOpenGLPixelTransferOptions * const options = nullptr);
513
514 // Compressed data upload
515 // ### Qt 6: remove the non-const void * overloads
516#if QT_DEPRECATED_SINCE(5, 3)
517 QT_DEPRECATED void setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace,
518 int dataSize, void *data,
519 const QOpenGLPixelTransferOptions * const options = nullptr);
520 QT_DEPRECATED void setCompressedData(int mipLevel, int layer,
521 int dataSize, void *data,
522 const QOpenGLPixelTransferOptions * const options = nullptr);
523 QT_DEPRECATED void setCompressedData(int mipLevel, int dataSize, void *data,
524 const QOpenGLPixelTransferOptions * const options = nullptr);
525 QT_DEPRECATED void setCompressedData(int dataSize, void *data,
526 const QOpenGLPixelTransferOptions * const options = nullptr);
527#endif // QT_DEPRECATED_SINCE(5, 3)
528
529 void setCompressedData(int mipLevel, int layer, CubeMapFace cubeFace,
530 int dataSize, const void *data,
531 const QOpenGLPixelTransferOptions * const options = nullptr);
532 void setCompressedData(int mipLevel, int layer, int layerCount, CubeMapFace cubeFace,
533 int dataSize, const void *data,
534 const QOpenGLPixelTransferOptions * const options = nullptr);
535 void setCompressedData(int mipLevel, int layer,
536 int dataSize, const void *data,
537 const QOpenGLPixelTransferOptions * const options = nullptr);
538 void setCompressedData(int mipLevel, int dataSize, const void *data,
539 const QOpenGLPixelTransferOptions * const options = nullptr);
540 void setCompressedData(int dataSize, const void *data,
541 const QOpenGLPixelTransferOptions * const options = nullptr);
542
543 // Helpful overloads for setData
544 void setData(const QImage& image, MipMapGeneration genMipMaps = GenerateMipMaps);
545
546 static bool hasFeature(Feature feature);
547
548 // Texture Parameters
549 void setMipBaseLevel(int baseLevel);
550 int mipBaseLevel() const;
551 void setMipMaxLevel(int maxLevel);
552 int mipMaxLevel() const;
553 void setMipLevelRange(int baseLevel, int maxLevel);
554 QPair<int, int> mipLevelRange() const;
555
556 void setAutoMipMapGenerationEnabled(bool enabled);
557 bool isAutoMipMapGenerationEnabled() const;
558
559 void generateMipMaps();
560 void generateMipMaps(int baseLevel, bool resetBaseLevel = true);
561
562 void setSwizzleMask(SwizzleComponent component, SwizzleValue value);
563 void setSwizzleMask(SwizzleValue r, SwizzleValue g,
564 SwizzleValue b, SwizzleValue a);
565 SwizzleValue swizzleMask(SwizzleComponent component) const;
566
567 enum DepthStencilMode {
568 DepthMode = 0x1902, // GL_DEPTH_COMPONENT
569 StencilMode = 0x1901 // GL_STENCIL_INDEX
570 };
571 Q_ENUM(DepthStencilMode)
572
573 void setDepthStencilMode(DepthStencilMode mode);
574 DepthStencilMode depthStencilMode() const;
575
576 enum ComparisonFunction {
577 CompareLessEqual = 0x0203, // GL_LEQUAL
578 CompareGreaterEqual = 0x0206, // GL_GEQUAL
579 CompareLess = 0x0201, // GL_LESS
580 CompareGreater = 0x0204, // GL_GREATER
581 CompareEqual = 0x0202, // GL_EQUAL
582 CommpareNotEqual = 0x0205, // GL_NOTEQUAL
583 CompareAlways = 0x0207, // GL_ALWAYS
584 CompareNever = 0x0200 // GL_NEVER
585 };
586 Q_ENUM(ComparisonFunction)
587
588 void setComparisonFunction(ComparisonFunction function);
589 ComparisonFunction comparisonFunction() const;
590
591 enum ComparisonMode {
592 CompareRefToTexture = 0x884E, // GL_COMPARE_REF_TO_TEXTURE
593 CompareNone = 0x0000 // GL_NONE
594 };
595
596 void setComparisonMode(ComparisonMode mode);
597 ComparisonMode comparisonMode() const;
598
599 // Sampling Parameters
600 enum Filter {
601 Nearest = 0x2600, // GL_NEAREST
602 Linear = 0x2601, // GL_LINEAR
603 NearestMipMapNearest = 0x2700, // GL_NEAREST_MIPMAP_NEAREST
604 NearestMipMapLinear = 0x2702, // GL_NEAREST_MIPMAP_LINEAR
605 LinearMipMapNearest = 0x2701, // GL_LINEAR_MIPMAP_NEAREST
606 LinearMipMapLinear = 0x2703 // GL_LINEAR_MIPMAP_LINEAR
607 };
608 Q_ENUM(Filter)
609
610 void setMinificationFilter(Filter filter);
611 Filter minificationFilter() const;
612 void setMagnificationFilter(Filter filter);
613 Filter magnificationFilter() const;
614 void setMinMagFilters(Filter minificationFilter,
615 Filter magnificationFilter);
616 QPair<Filter, Filter> minMagFilters() const;
617 void setMaximumAnisotropy(float anisotropy);
618 float maximumAnisotropy() const;
619
620 void setWrapMode(WrapMode mode);
621 void setWrapMode(CoordinateDirection direction, WrapMode mode);
622 WrapMode wrapMode(CoordinateDirection direction) const;
623
624 void setBorderColor(QColor color);
625 void setBorderColor(float r, float g, float b, float a);
626 void setBorderColor(int r, int g, int b, int a);
627 void setBorderColor(uint r, uint g, uint b, uint a);
628
629 QColor borderColor() const;
630 void borderColor(float *border) const;
631 void borderColor(int *border) const;
632 void borderColor(unsigned int *border) const;
633
634 void setMinimumLevelOfDetail(float value);
635 float minimumLevelOfDetail() const;
636 void setMaximumLevelOfDetail(float value);
637 float maximumLevelOfDetail() const;
638 void setLevelOfDetailRange(float min, float max);
639 QPair<float, float> levelOfDetailRange() const;
640 void setLevelofDetailBias(float bias);
641 float levelofDetailBias() const;
642
643#ifndef QT_NO_DEBUG_STREAM
644 friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QOpenGLTexture *t);
645#endif
646
647private:
648 Q_DISABLE_COPY(QOpenGLTexture)
649 Q_DECLARE_PRIVATE(QOpenGLTexture)
650 QScopedPointer<QOpenGLTexturePrivate> d_ptr;
651};
652
653Q_DECLARE_OPERATORS_FOR_FLAGS(QOpenGLTexture::Features)
654
655#ifndef QT_NO_DEBUG_STREAM
656Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QOpenGLTexture *t);
657#endif
658
659QT_END_NAMESPACE
660
661#endif // QT_NO_OPENGL
662
663#endif // QOPENGLABSTRACTTEXTURE_H
664

source code of qtbase/src/gui/opengl/qopengltexture.h