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 SHADERHELPER_P_H
41#define SHADERHELPER_P_H
42
43#include "datavisualizationglobal_p.h"
44
45QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram)
46
47QT_BEGIN_NAMESPACE_DATAVISUALIZATION
48
49class ShaderHelper
50{
51 public:
52 ShaderHelper(QObject *parent,
53 const QString &vertexShader = QString(),
54 const QString &fragmentShader = QString(),
55 const QString &texture = QString(),
56 const QString &depthTexture = QString());
57 ~ShaderHelper();
58
59 void setShaders(const QString &vertexShader, const QString &fragmentShader);
60 void setTextures(const QString &texture, const QString &depthTexture);
61
62 void initialize();
63 bool testCompile();
64 void bind();
65 void release();
66 void setUniformValue(GLint uniform, const QVector2D &value);
67 void setUniformValue(GLint uniform, const QVector3D &value);
68 void setUniformValue(GLint uniform, const QVector4D &value);
69 void setUniformValue(GLint uniform, const QMatrix4x4 &value);
70 void setUniformValue(GLint uniform, GLfloat value);
71 void setUniformValue(GLint uniform, GLint value);
72 void setUniformValueArray(GLint uniform, const QVector4D *values, int count);
73
74 GLint MVP();
75 GLint view();
76 GLint model();
77 GLint nModel();
78 GLint depth();
79 GLint lightP();
80 GLint lightS();
81 GLint ambientS();
82 GLint shadowQ();
83 GLint color();
84 GLint texture();
85 GLint shadow();
86 GLint gradientMin();
87 GLint gradientHeight();
88 GLint lightColor();
89 GLint volumeSliceIndices();
90 GLint colorIndex();
91 GLint cameraPositionRelativeToModel();
92 GLint color8Bit();
93 GLint textureDimensions();
94 GLint sampleCount();
95 GLint alphaMultiplier();
96 GLint preserveOpacity();
97 GLint maxBounds();
98 GLint minBounds();
99 GLint sliceFrameWidth();
100
101 GLint posAtt();
102 GLint uvAtt();
103 GLint normalAtt();
104
105 private:
106 QObject *m_caller;
107 QOpenGLShaderProgram *m_program;
108
109 QString m_vertexShaderFile;
110 QString m_fragmentShaderFile;
111
112 QString m_textureFile;
113 QString m_depthTextureFile;
114
115 GLint m_positionAttr;
116 GLint m_uvAttr;
117 GLint m_normalAttr;
118
119 GLint m_colorUniform;
120 GLint m_viewMatrixUniform;
121 GLint m_modelMatrixUniform;
122 GLint m_invTransModelMatrixUniform;
123 GLint m_depthMatrixUniform;
124 GLint m_mvpMatrixUniform;
125 GLint m_lightPositionUniform;
126 GLint m_lightStrengthUniform;
127 GLint m_ambientStrengthUniform;
128 GLint m_shadowQualityUniform;
129 GLint m_textureUniform;
130 GLint m_shadowUniform;
131 GLint m_gradientMinUniform;
132 GLint m_gradientHeightUniform;
133 GLint m_lightColorUniform;
134 GLint m_volumeSliceIndicesUniform;
135 GLint m_colorIndexUniform;
136 GLint m_cameraPositionRelativeToModelUniform;
137 GLint m_color8BitUniform;
138 GLint m_textureDimensionsUniform;
139 GLint m_sampleCountUniform;
140 GLint m_alphaMultiplierUniform;
141 GLint m_preserveOpacityUniform;
142 GLint m_minBoundsUniform;
143 GLint m_maxBoundsUniform;
144 GLint m_sliceFrameWidthUniform;
145
146 GLboolean m_initialized;
147};
148
149QT_END_NAMESPACE_DATAVISUALIZATION
150
151#endif
152

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