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 SHADERHELPER_P_H |
15 | #define SHADERHELPER_P_H |
16 | |
17 | #include "datavisualizationglobal_p.h" |
18 | |
19 | QT_FORWARD_DECLARE_CLASS(QOpenGLShaderProgram) |
20 | |
21 | QT_BEGIN_NAMESPACE |
22 | |
23 | class ShaderHelper |
24 | { |
25 | public: |
26 | ShaderHelper(QObject *parent, |
27 | const QString &vertexShader = QString(), |
28 | const QString &fragmentShader = QString(), |
29 | const QString &texture = QString(), |
30 | const QString &depthTexture = QString()); |
31 | ~ShaderHelper(); |
32 | |
33 | void setShaders(const QString &vertexShader, const QString &fragmentShader); |
34 | void setTextures(const QString &texture, const QString &depthTexture); |
35 | |
36 | void initialize(); |
37 | bool testCompile(); |
38 | void bind(); |
39 | void release(); |
40 | void setUniformValue(GLint uniform, const QVector2D &value); |
41 | void setUniformValue(GLint uniform, const QVector3D &value); |
42 | void setUniformValue(GLint uniform, const QVector4D &value); |
43 | void setUniformValue(GLint uniform, const QMatrix4x4 &value); |
44 | void setUniformValue(GLint uniform, GLfloat value); |
45 | void setUniformValue(GLint uniform, GLint value); |
46 | void setUniformValueArray(GLint uniform, const QVector4D *values, int count); |
47 | |
48 | GLint MVP(); |
49 | GLint view(); |
50 | GLint model(); |
51 | GLint nModel(); |
52 | GLint depth(); |
53 | GLint lightP(); |
54 | GLint lightS(); |
55 | GLint ambientS(); |
56 | GLint shadowQ(); |
57 | GLint color(); |
58 | GLint texture(); |
59 | GLint shadow(); |
60 | GLint gradientMin(); |
61 | GLint gradientHeight(); |
62 | GLint lightColor(); |
63 | GLint volumeSliceIndices(); |
64 | GLint colorIndex(); |
65 | GLint cameraPositionRelativeToModel(); |
66 | GLint color8Bit(); |
67 | GLint textureDimensions(); |
68 | GLint sampleCount(); |
69 | GLint alphaMultiplier(); |
70 | GLint preserveOpacity(); |
71 | GLint maxBounds(); |
72 | GLint minBounds(); |
73 | GLint sliceFrameWidth(); |
74 | |
75 | GLint posAtt(); |
76 | GLint uvAtt(); |
77 | GLint normalAtt(); |
78 | |
79 | private: |
80 | QObject *m_caller; |
81 | QOpenGLShaderProgram *m_program; |
82 | |
83 | QString m_vertexShaderFile; |
84 | QString m_fragmentShaderFile; |
85 | |
86 | QString m_textureFile; |
87 | QString m_depthTextureFile; |
88 | |
89 | GLint m_positionAttr; |
90 | GLint m_uvAttr; |
91 | GLint m_normalAttr; |
92 | |
93 | GLint m_colorUniform; |
94 | GLint m_viewMatrixUniform; |
95 | GLint m_modelMatrixUniform; |
96 | GLint m_invTransModelMatrixUniform; |
97 | GLint m_depthMatrixUniform; |
98 | GLint m_mvpMatrixUniform; |
99 | GLint m_lightPositionUniform; |
100 | GLint m_lightStrengthUniform; |
101 | GLint m_ambientStrengthUniform; |
102 | GLint m_shadowQualityUniform; |
103 | GLint m_textureUniform; |
104 | GLint m_shadowUniform; |
105 | GLint m_gradientMinUniform; |
106 | GLint m_gradientHeightUniform; |
107 | GLint m_lightColorUniform; |
108 | GLint m_volumeSliceIndicesUniform; |
109 | GLint m_colorIndexUniform; |
110 | GLint m_cameraPositionRelativeToModelUniform; |
111 | GLint m_color8BitUniform; |
112 | GLint m_textureDimensionsUniform; |
113 | GLint m_sampleCountUniform; |
114 | GLint m_alphaMultiplierUniform; |
115 | GLint m_preserveOpacityUniform; |
116 | GLint m_minBoundsUniform; |
117 | GLint m_maxBoundsUniform; |
118 | GLint m_sliceFrameWidthUniform; |
119 | |
120 | GLboolean m_initialized; |
121 | }; |
122 | |
123 | QT_END_NAMESPACE |
124 | |
125 | #endif |
126 | |