1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtDataVisualization API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef TEXTUREHELPER_P_H |
15 | #define TEXTUREHELPER_P_H |
16 | |
17 | #include "datavisualizationglobal_p.h" |
18 | #include <QtGui/QRgb> |
19 | #include <QtGui/QLinearGradient> |
20 | #if !QT_CONFIG(opengles2) |
21 | // 3D Textures are not supported by ES set |
22 | # include <QtOpenGL/QOpenGLFunctions_2_1> |
23 | #endif |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class TextureHelper : protected QOpenGLFunctions |
28 | { |
29 | public: |
30 | TextureHelper(); |
31 | ~TextureHelper(); |
32 | |
33 | // Ownership of created texture is transferred to caller |
34 | GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false, |
35 | bool convert = true, bool smoothScale = true, bool clampY = false); |
36 | GLuint create3DTexture(const QList<uchar> *data, int width, int height, int depth, |
37 | QImage::Format dataFormat); |
38 | GLuint createCubeMapTexture(const QImage &image, bool useTrilinearFiltering = false); |
39 | // Returns selection texture and inserts generated framebuffers to framebuffer parameters |
40 | GLuint createSelectionTexture(const QSize &size, GLuint &frameBuffer, GLuint &depthBuffer); |
41 | GLuint createCursorPositionTexture(const QSize &size, GLuint &frameBuffer); |
42 | GLuint createUniformTexture(const QColor &color); |
43 | GLuint createGradientTexture(const QLinearGradient &gradient); |
44 | GLuint createDepthTexture(const QSize &size, GLuint textureSize); |
45 | // Returns depth texture and inserts generated framebuffer to parameter |
46 | GLuint createDepthTextureFrameBuffer(const QSize &size, GLuint &frameBuffer, GLuint textureSize); |
47 | void deleteTexture(GLuint *texture); |
48 | |
49 | private: |
50 | QImage convertToGLFormat(const QImage &srcImage); |
51 | void convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage, GLenum texture_format); |
52 | QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format); |
53 | |
54 | #if !QT_CONFIG(opengles2) |
55 | QOpenGLFunctions_2_1 *m_openGlFunctions_2_1 = nullptr; |
56 | #endif |
57 | friend class Bars3DRenderer; |
58 | friend class Surface3DRenderer; |
59 | friend class Scatter3DRenderer; |
60 | friend class Abstract3DRenderer; |
61 | }; |
62 | |
63 | QT_END_NAMESPACE |
64 | |
65 | #endif |
66 | |