author | Eckhart Koeppen <eckhart.koppen@nokia.com> |
Wed, 21 Apr 2010 12:15:23 +0300 | |
branch | RCL_3 |
changeset 12 | cc75c76972ee |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the QtOpenGL module of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
15 |
** |
|
16 |
** GNU Lesser General Public License Usage |
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 |
** General Public License version 2.1 as published by the Free Software |
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 |
** packaging of this file. Please review the following information to |
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 |
** |
|
24 |
** In addition, as a special exception, Nokia gives you certain additional |
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 |
** |
|
28 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#ifndef QGLSHADERPROGRAM_H |
|
43 |
#define QGLSHADERPROGRAM_H |
|
44 |
||
45 |
#include <QtOpenGL/qgl.h> |
|
46 |
#include <QtGui/qvector2d.h> |
|
47 |
#include <QtGui/qvector3d.h> |
|
48 |
#include <QtGui/qvector4d.h> |
|
49 |
#include <QtGui/qmatrix4x4.h> |
|
50 |
||
51 |
QT_BEGIN_HEADER |
|
52 |
||
53 |
QT_BEGIN_NAMESPACE |
|
54 |
||
55 |
QT_MODULE(OpenGL) |
|
56 |
||
57 |
#if !defined(QT_OPENGL_ES_1_CL) && !defined(QT_OPENGL_ES_1) |
|
58 |
||
59 |
class QGLShaderProgram; |
|
60 |
class QGLShaderPrivate; |
|
61 |
||
62 |
class Q_OPENGL_EXPORT QGLShader : public QObject |
|
63 |
{ |
|
64 |
Q_OBJECT |
|
65 |
public: |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
66 |
enum ShaderTypeBit |
0 | 67 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
68 |
Vertex = 0x0001, |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
69 |
Fragment = 0x0002 |
0 | 70 |
}; |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
71 |
Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit) |
0 | 72 |
|
73 |
explicit QGLShader(QGLShader::ShaderType type, QObject *parent = 0); |
|
74 |
QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent = 0); |
|
75 |
virtual ~QGLShader(); |
|
76 |
||
77 |
QGLShader::ShaderType shaderType() const; |
|
78 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
79 |
bool compileSourceCode(const char *source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
bool compileSourceCode(const QByteArray& source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
bool compileSourceCode(const QString& source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
82 |
bool compileSourceFile(const QString& fileName); |
0 | 83 |
|
84 |
QByteArray sourceCode() const; |
|
85 |
||
86 |
bool isCompiled() const; |
|
87 |
QString log() const; |
|
88 |
||
89 |
GLuint shaderId() const; |
|
90 |
||
91 |
private: |
|
92 |
friend class QGLShaderProgram; |
|
93 |
||
94 |
Q_DISABLE_COPY(QGLShader) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
Q_DECLARE_PRIVATE(QGLShader) |
0 | 96 |
}; |
97 |
||
98 |
Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType) |
|
99 |
||
100 |
||
101 |
class QGLShaderProgramPrivate; |
|
102 |
||
103 |
class Q_OPENGL_EXPORT QGLShaderProgram : public QObject |
|
104 |
{ |
|
105 |
Q_OBJECT |
|
106 |
public: |
|
107 |
explicit QGLShaderProgram(QObject *parent = 0); |
|
108 |
explicit QGLShaderProgram(const QGLContext *context, QObject *parent = 0); |
|
109 |
virtual ~QGLShaderProgram(); |
|
110 |
||
111 |
bool addShader(QGLShader *shader); |
|
112 |
void removeShader(QGLShader *shader); |
|
113 |
QList<QGLShader *> shaders() const; |
|
114 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
115 |
bool addShaderFromSourceCode(QGLShader::ShaderType type, const char *source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
bool addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
117 |
bool addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
bool addShaderFromSourceFile(QGLShader::ShaderType type, const QString& fileName); |
0 | 119 |
|
120 |
void removeAllShaders(); |
|
121 |
||
122 |
virtual bool link(); |
|
123 |
bool isLinked() const; |
|
124 |
QString log() const; |
|
125 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
126 |
bool bind(); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
127 |
void release(); |
0 | 128 |
|
129 |
GLuint programId() const; |
|
130 |
||
131 |
void bindAttributeLocation(const char *name, int location); |
|
132 |
void bindAttributeLocation(const QByteArray& name, int location); |
|
133 |
void bindAttributeLocation(const QString& name, int location); |
|
134 |
||
135 |
int attributeLocation(const char *name) const; |
|
136 |
int attributeLocation(const QByteArray& name) const; |
|
137 |
int attributeLocation(const QString& name) const; |
|
138 |
||
139 |
void setAttributeValue(int location, GLfloat value); |
|
140 |
void setAttributeValue(int location, GLfloat x, GLfloat y); |
|
141 |
void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z); |
|
142 |
void setAttributeValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); |
|
143 |
void setAttributeValue(int location, const QVector2D& value); |
|
144 |
void setAttributeValue(int location, const QVector3D& value); |
|
145 |
void setAttributeValue(int location, const QVector4D& value); |
|
146 |
void setAttributeValue(int location, const QColor& value); |
|
147 |
void setAttributeValue(int location, const GLfloat *values, int columns, int rows); |
|
148 |
||
149 |
void setAttributeValue(const char *name, GLfloat value); |
|
150 |
void setAttributeValue(const char *name, GLfloat x, GLfloat y); |
|
151 |
void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z); |
|
152 |
void setAttributeValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); |
|
153 |
void setAttributeValue(const char *name, const QVector2D& value); |
|
154 |
void setAttributeValue(const char *name, const QVector3D& value); |
|
155 |
void setAttributeValue(const char *name, const QVector4D& value); |
|
156 |
void setAttributeValue(const char *name, const QColor& value); |
|
157 |
void setAttributeValue(const char *name, const GLfloat *values, int columns, int rows); |
|
158 |
||
159 |
void setAttributeArray |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
160 |
(int location, const GLfloat *values, int tupleSize, int stride = 0); |
0 | 161 |
void setAttributeArray |
162 |
(int location, const QVector2D *values, int stride = 0); |
|
163 |
void setAttributeArray |
|
164 |
(int location, const QVector3D *values, int stride = 0); |
|
165 |
void setAttributeArray |
|
166 |
(int location, const QVector4D *values, int stride = 0); |
|
167 |
void setAttributeArray |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
168 |
(const char *name, const GLfloat *values, int tupleSize, int stride = 0); |
0 | 169 |
void setAttributeArray |
170 |
(const char *name, const QVector2D *values, int stride = 0); |
|
171 |
void setAttributeArray |
|
172 |
(const char *name, const QVector3D *values, int stride = 0); |
|
173 |
void setAttributeArray |
|
174 |
(const char *name, const QVector4D *values, int stride = 0); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
175 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
176 |
void enableAttributeArray(int location); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
177 |
void enableAttributeArray(const char *name); |
0 | 178 |
void disableAttributeArray(int location); |
179 |
void disableAttributeArray(const char *name); |
|
180 |
||
181 |
int uniformLocation(const char *name) const; |
|
182 |
int uniformLocation(const QByteArray& name) const; |
|
183 |
int uniformLocation(const QString& name) const; |
|
184 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
185 |
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
186 |
void setUniformValue(int location, QMacCompatGLint value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
187 |
void setUniformValue(int location, QMacCompatGLuint value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
188 |
void setUniformValue(const char *name, QMacCompatGLint value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
void setUniformValue(const char *name, QMacCompatGLuint value); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
190 |
void setUniformValueArray(int location, const QMacCompatGLint *values, int count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
void setUniformValueArray(int location, const QMacCompatGLuint *values, int count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
192 |
void setUniformValueArray(const char *name, const QMacCompatGLint *values, int count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
void setUniformValueArray(const char *name, const QMacCompatGLuint *values, int count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
#endif |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
|
0 | 196 |
void setUniformValue(int location, GLfloat value); |
197 |
void setUniformValue(int location, GLint value); |
|
198 |
void setUniformValue(int location, GLuint value); |
|
199 |
void setUniformValue(int location, GLfloat x, GLfloat y); |
|
200 |
void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z); |
|
201 |
void setUniformValue(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); |
|
202 |
void setUniformValue(int location, const QVector2D& value); |
|
203 |
void setUniformValue(int location, const QVector3D& value); |
|
204 |
void setUniformValue(int location, const QVector4D& value); |
|
205 |
void setUniformValue(int location, const QColor& color); |
|
206 |
void setUniformValue(int location, const QPoint& point); |
|
207 |
void setUniformValue(int location, const QPointF& point); |
|
208 |
void setUniformValue(int location, const QSize& size); |
|
209 |
void setUniformValue(int location, const QSizeF& size); |
|
210 |
void setUniformValue(int location, const QMatrix2x2& value); |
|
211 |
void setUniformValue(int location, const QMatrix2x3& value); |
|
212 |
void setUniformValue(int location, const QMatrix2x4& value); |
|
213 |
void setUniformValue(int location, const QMatrix3x2& value); |
|
214 |
void setUniformValue(int location, const QMatrix3x3& value); |
|
215 |
void setUniformValue(int location, const QMatrix3x4& value); |
|
216 |
void setUniformValue(int location, const QMatrix4x2& value); |
|
217 |
void setUniformValue(int location, const QMatrix4x3& value); |
|
218 |
void setUniformValue(int location, const QMatrix4x4& value); |
|
219 |
void setUniformValue(int location, const GLfloat value[4][4]); |
|
220 |
void setUniformValue(int location, const QTransform& value); |
|
221 |
||
222 |
void setUniformValue(const char *name, GLfloat value); |
|
223 |
void setUniformValue(const char *name, GLint value); |
|
224 |
void setUniformValue(const char *name, GLuint value); |
|
225 |
void setUniformValue(const char *name, GLfloat x, GLfloat y); |
|
226 |
void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z); |
|
227 |
void setUniformValue(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); |
|
228 |
void setUniformValue(const char *name, const QVector2D& value); |
|
229 |
void setUniformValue(const char *name, const QVector3D& value); |
|
230 |
void setUniformValue(const char *name, const QVector4D& value); |
|
231 |
void setUniformValue(const char *name, const QColor& color); |
|
232 |
void setUniformValue(const char *name, const QPoint& point); |
|
233 |
void setUniformValue(const char *name, const QPointF& point); |
|
234 |
void setUniformValue(const char *name, const QSize& size); |
|
235 |
void setUniformValue(const char *name, const QSizeF& size); |
|
236 |
void setUniformValue(const char *name, const QMatrix2x2& value); |
|
237 |
void setUniformValue(const char *name, const QMatrix2x3& value); |
|
238 |
void setUniformValue(const char *name, const QMatrix2x4& value); |
|
239 |
void setUniformValue(const char *name, const QMatrix3x2& value); |
|
240 |
void setUniformValue(const char *name, const QMatrix3x3& value); |
|
241 |
void setUniformValue(const char *name, const QMatrix3x4& value); |
|
242 |
void setUniformValue(const char *name, const QMatrix4x2& value); |
|
243 |
void setUniformValue(const char *name, const QMatrix4x3& value); |
|
244 |
void setUniformValue(const char *name, const QMatrix4x4& value); |
|
245 |
void setUniformValue(const char *name, const GLfloat value[4][4]); |
|
246 |
void setUniformValue(const char *name, const QTransform& value); |
|
247 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
void setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize); |
0 | 249 |
void setUniformValueArray(int location, const GLint *values, int count); |
250 |
void setUniformValueArray(int location, const GLuint *values, int count); |
|
251 |
void setUniformValueArray(int location, const QVector2D *values, int count); |
|
252 |
void setUniformValueArray(int location, const QVector3D *values, int count); |
|
253 |
void setUniformValueArray(int location, const QVector4D *values, int count); |
|
254 |
void setUniformValueArray(int location, const QMatrix2x2 *values, int count); |
|
255 |
void setUniformValueArray(int location, const QMatrix2x3 *values, int count); |
|
256 |
void setUniformValueArray(int location, const QMatrix2x4 *values, int count); |
|
257 |
void setUniformValueArray(int location, const QMatrix3x2 *values, int count); |
|
258 |
void setUniformValueArray(int location, const QMatrix3x3 *values, int count); |
|
259 |
void setUniformValueArray(int location, const QMatrix3x4 *values, int count); |
|
260 |
void setUniformValueArray(int location, const QMatrix4x2 *values, int count); |
|
261 |
void setUniformValueArray(int location, const QMatrix4x3 *values, int count); |
|
262 |
void setUniformValueArray(int location, const QMatrix4x4 *values, int count); |
|
263 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
void setUniformValueArray(const char *name, const GLfloat *values, int count, int tupleSize); |
0 | 265 |
void setUniformValueArray(const char *name, const GLint *values, int count); |
266 |
void setUniformValueArray(const char *name, const GLuint *values, int count); |
|
267 |
void setUniformValueArray(const char *name, const QVector2D *values, int count); |
|
268 |
void setUniformValueArray(const char *name, const QVector3D *values, int count); |
|
269 |
void setUniformValueArray(const char *name, const QVector4D *values, int count); |
|
270 |
void setUniformValueArray(const char *name, const QMatrix2x2 *values, int count); |
|
271 |
void setUniformValueArray(const char *name, const QMatrix2x3 *values, int count); |
|
272 |
void setUniformValueArray(const char *name, const QMatrix2x4 *values, int count); |
|
273 |
void setUniformValueArray(const char *name, const QMatrix3x2 *values, int count); |
|
274 |
void setUniformValueArray(const char *name, const QMatrix3x3 *values, int count); |
|
275 |
void setUniformValueArray(const char *name, const QMatrix3x4 *values, int count); |
|
276 |
void setUniformValueArray(const char *name, const QMatrix4x2 *values, int count); |
|
277 |
void setUniformValueArray(const char *name, const QMatrix4x3 *values, int count); |
|
278 |
void setUniformValueArray(const char *name, const QMatrix4x4 *values, int count); |
|
279 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
280 |
static bool hasOpenGLShaderPrograms(const QGLContext *context = 0); |
0 | 281 |
|
282 |
private Q_SLOTS: |
|
283 |
void shaderDestroyed(); |
|
284 |
||
285 |
private: |
|
286 |
Q_DISABLE_COPY(QGLShaderProgram) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
Q_DECLARE_PRIVATE(QGLShaderProgram) |
0 | 288 |
|
289 |
bool init(); |
|
290 |
}; |
|
291 |
||
292 |
#endif |
|
293 |
||
294 |
QT_END_NAMESPACE |
|
295 |
||
296 |
QT_END_HEADER |
|
297 |
||
298 |
#endif |