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