1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Data Visualization module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL$
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 General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 or (at your option) any later version
20** approved by the KDE Free Qt Foundation. The licenses are as published by
21** the Free Software Foundation and appearing in the file LICENSE.GPL3
22** included in the packaging of this file. Please review the following
23** information to ensure the GNU General Public License requirements will
24** be met: https://www.gnu.org/licenses/gpl-3.0.html.
25**
26** $QT_END_LICENSE$
27**
28****************************************************************************/
29
30//
31// W A R N I N G
32// -------------
33//
34// This file is not part of the QtDataVisualization API. It exists purely as an
35// implementation detail. This header file may change from version to
36// version without notice, or even be removed.
37//
38// We mean it.
39
40#ifndef TEXTUREHELPER_P_H
41#define TEXTUREHELPER_P_H
42
43#include "datavisualizationglobal_p.h"
44#include <QtGui/QRgb>
45#include <QtGui/QLinearGradient>
46#if !defined(QT_OPENGL_ES_2)
47// 3D Textures are not supported by ES set
48# include <QtGui/QOpenGLFunctions_2_1>
49#endif
50
51QT_BEGIN_NAMESPACE_DATAVISUALIZATION
52
53class TextureHelper : protected QOpenGLFunctions
54{
55 public:
56 TextureHelper();
57 ~TextureHelper();
58
59 // Ownership of created texture is transferred to caller
60 GLuint create2DTexture(const QImage &image, bool useTrilinearFiltering = false,
61 bool convert = true, bool smoothScale = true, bool clampY = false);
62 GLuint create3DTexture(const QVector<uchar> *data, int width, int height, int depth,
63 QImage::Format dataFormat);
64 GLuint createCubeMapTexture(const QImage &image, bool useTrilinearFiltering = false);
65 // Returns selection texture and inserts generated framebuffers to framebuffer parameters
66 GLuint createSelectionTexture(const QSize &size, GLuint &frameBuffer, GLuint &depthBuffer);
67 GLuint createCursorPositionTexture(const QSize &size, GLuint &frameBuffer);
68 GLuint createUniformTexture(const QColor &color);
69 GLuint createGradientTexture(const QLinearGradient &gradient);
70 GLuint createDepthTexture(const QSize &size, GLuint textureSize);
71 // Returns depth texture and inserts generated framebuffer to parameter
72 GLuint createDepthTextureFrameBuffer(const QSize &size, GLuint &frameBuffer, GLuint textureSize);
73 void deleteTexture(GLuint *texture);
74
75 private:
76 QImage convertToGLFormat(const QImage &srcImage);
77 void convertToGLFormatHelper(QImage &dstImage, const QImage &srcImage, GLenum texture_format);
78 QRgb qt_gl_convertToGLFormatHelper(QRgb src_pixel, GLenum texture_format);
79
80#if !defined(QT_OPENGL_ES_2)
81 QOpenGLFunctions_2_1 *m_openGlFunctions_2_1; // Not owned
82#endif
83 friend class Bars3DRenderer;
84 friend class Surface3DRenderer;
85 friend class Scatter3DRenderer;
86 friend class Abstract3DRenderer;
87};
88
89QT_END_NAMESPACE_DATAVISUALIZATION
90
91#endif
92

source code of qtdatavis3d/src/datavisualization/utils/texturehelper_p.h