42 #ifndef QGLSHADERPROGRAM_H
43 #define QGLSHADERPROGRAM_H
57 #if !defined(QT_OPENGL_ES_1)
60 class QGLShaderPrivate;
72 Q_DECLARE_FLAGS(ShaderType, ShaderTypeBit)
78 QGLShader::ShaderType shaderType() const;
80 bool compileSourceCode(const
char *
source);
81 bool compileSourceCode(const
QByteArray& source);
82 bool compileSourceCode(const
QString& source);
83 bool compileSourceFile(const
QString& fileName);
87 bool isCompiled() const;
92 static
bool hasOpenGLShaders(ShaderType type, const
QGLContext *context = 0);
97 Q_DISABLE_COPY(QGLShader)
98 Q_DECLARE_PRIVATE(QGLShader)
101 Q_DECLARE_OPERATORS_FOR_FLAGS(QGLShader::ShaderType)
104 class QGLShaderProgramPrivate;
106 #ifndef GL_EXT_geometry_shader4
107 # define GL_LINES_ADJACENCY_EXT 0xA
108 # define GL_LINE_STRIP_ADJACENCY_EXT 0xB
109 # define GL_TRIANGLES_ADJACENCY_EXT 0xC
110 # define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0xD
114 class Q_OPENGL_EXPORT QGLShaderProgram :
public QObject
118 explicit QGLShaderProgram(
QObject *parent = 0);
120 virtual ~QGLShaderProgram();
122 bool addShader(QGLShader *
shader);
123 void removeShader(QGLShader *shader);
126 bool addShaderFromSourceCode(QGLShader::ShaderType type,
const char *source);
127 bool addShaderFromSourceCode(QGLShader::ShaderType type,
const QByteArray& source);
128 bool addShaderFromSourceCode(QGLShader::ShaderType type,
const QString& source);
129 bool addShaderFromSourceFile(QGLShader::ShaderType type,
const QString& fileName);
131 void removeAllShaders();
134 bool isLinked()
const;
142 int maxGeometryOutputVertices()
const;
144 void setGeometryOutputVertexCount(
int count);
145 int geometryOutputVertexCount()
const;
147 void setGeometryInputType(
GLenum inputType);
148 GLenum geometryInputType()
const;
150 void setGeometryOutputType(
GLenum outputType);
151 GLenum geometryOutputType()
const;
153 void bindAttributeLocation(
const char *
name,
int location);
154 void bindAttributeLocation(
const QByteArray& name,
int location);
155 void bindAttributeLocation(
const QString& name,
int location);
157 int attributeLocation(
const char *name)
const;
158 int attributeLocation(
const QByteArray& name)
const;
159 int attributeLocation(
const QString& name)
const;
161 void setAttributeValue(
int location, GLfloat
value);
162 void setAttributeValue(
int location, GLfloat
x, GLfloat
y);
163 void setAttributeValue(
int location, GLfloat x, GLfloat y, GLfloat
z);
164 void setAttributeValue(
int location, GLfloat x, GLfloat y, GLfloat z, GLfloat
w);
165 void setAttributeValue(
int location,
const QVector2D& value);
166 void setAttributeValue(
int location,
const QVector3D& value);
167 void setAttributeValue(
int location,
const QVector4D& value);
168 void setAttributeValue(
int location,
const QColor& value);
169 void setAttributeValue(
int location,
const GLfloat *
values,
int columns,
int rows);
171 void setAttributeValue(
const char *name, GLfloat value);
172 void setAttributeValue(
const char *name, GLfloat x, GLfloat y);
173 void setAttributeValue(
const char *name, GLfloat x, GLfloat y, GLfloat z);
174 void setAttributeValue(
const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
175 void setAttributeValue(
const char *name,
const QVector2D& value);
176 void setAttributeValue(
const char *name,
const QVector3D& value);
177 void setAttributeValue(
const char *name,
const QVector4D& value);
178 void setAttributeValue(
const char *name,
const QColor& value);
179 void setAttributeValue(
const char *name,
const GLfloat *values,
int columns,
int rows);
181 void setAttributeArray
182 (
int location,
const GLfloat *values,
int tupleSize,
int stride = 0);
183 void setAttributeArray
185 void setAttributeArray
187 void setAttributeArray
189 void setAttributeArray
190 (
int location,
GLenum type,
const void *values,
int tupleSize,
int stride = 0);
191 void setAttributeArray
192 (
const char *name,
const GLfloat *values,
int tupleSize,
int stride = 0);
193 void setAttributeArray
195 void setAttributeArray
197 void setAttributeArray
199 void setAttributeArray
200 (
const char *name,
GLenum type,
const void *values,
int tupleSize,
int stride = 0);
202 void setAttributeBuffer
204 void setAttributeBuffer
205 (
const char *name,
GLenum type,
int offset,
int tupleSize,
int stride = 0);
207 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
208 void setAttributeArray
209 (
int location, QMacCompatGLenum type,
const void *values,
int tupleSize,
int stride = 0);
210 void setAttributeArray
211 (
const char *name, QMacCompatGLenum type,
const void *values,
int tupleSize,
int stride = 0);
212 void setAttributeBuffer
213 (
int location, QMacCompatGLenum type,
int offset,
int tupleSize,
int stride = 0);
214 void setAttributeBuffer
215 (
const char *name, QMacCompatGLenum type,
int offset,
int tupleSize,
int stride = 0);
218 void enableAttributeArray(
int location);
219 void enableAttributeArray(
const char *name);
220 void disableAttributeArray(
int location);
221 void disableAttributeArray(
const char *name);
223 int uniformLocation(
const char *name)
const;
224 int uniformLocation(
const QByteArray& name)
const;
225 int uniformLocation(
const QString& name)
const;
227 #ifdef Q_MAC_COMPAT_GL_FUNCTIONS
228 void setUniformValue(
int location, QMacCompatGLint value);
229 void setUniformValue(
int location, QMacCompatGLuint value);
230 void setUniformValue(
const char *name, QMacCompatGLint value);
231 void setUniformValue(
const char *name, QMacCompatGLuint value);
232 void setUniformValueArray(
int location,
const QMacCompatGLint *values,
int count);
233 void setUniformValueArray(
int location,
const QMacCompatGLuint *values,
int count);
234 void setUniformValueArray(
const char *name,
const QMacCompatGLint *values,
int count);
235 void setUniformValueArray(
const char *name,
const QMacCompatGLuint *values,
int count);
238 void setUniformValue(
int location, GLfloat value);
239 void setUniformValue(
int location,
GLint value);
240 void setUniformValue(
int location,
GLuint value);
241 void setUniformValue(
int location, GLfloat x, GLfloat y);
242 void setUniformValue(
int location, GLfloat x, GLfloat y, GLfloat z);
243 void setUniformValue(
int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
244 void setUniformValue(
int location,
const QVector2D& value);
245 void setUniformValue(
int location,
const QVector3D& value);
246 void setUniformValue(
int location,
const QVector4D& value);
247 void setUniformValue(
int location,
const QColor&
color);
248 void setUniformValue(
int location,
const QPoint& point);
249 void setUniformValue(
int location,
const QPointF& point);
250 void setUniformValue(
int location,
const QSize&
size);
251 void setUniformValue(
int location,
const QSizeF& size);
252 void setUniformValue(
int location,
const QMatrix2x2& value);
253 void setUniformValue(
int location,
const QMatrix2x3& value);
254 void setUniformValue(
int location,
const QMatrix2x4& value);
255 void setUniformValue(
int location,
const QMatrix3x2& value);
256 void setUniformValue(
int location,
const QMatrix3x3& value);
257 void setUniformValue(
int location,
const QMatrix3x4& value);
258 void setUniformValue(
int location,
const QMatrix4x2& value);
259 void setUniformValue(
int location,
const QMatrix4x3& value);
260 void setUniformValue(
int location,
const QMatrix4x4& value);
261 void setUniformValue(
int location,
const GLfloat value[2][2]);
262 void setUniformValue(
int location,
const GLfloat value[3][3]);
263 void setUniformValue(
int location,
const GLfloat value[4][4]);
264 void setUniformValue(
int location,
const QTransform& value);
266 void setUniformValue(
const char *name, GLfloat value);
267 void setUniformValue(
const char *name,
GLint value);
268 void setUniformValue(
const char *name,
GLuint value);
269 void setUniformValue(
const char *name, GLfloat x, GLfloat y);
270 void setUniformValue(
const char *name, GLfloat x, GLfloat y, GLfloat z);
271 void setUniformValue(
const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
272 void setUniformValue(
const char *name,
const QVector2D& value);
273 void setUniformValue(
const char *name,
const QVector3D& value);
274 void setUniformValue(
const char *name,
const QVector4D& value);
275 void setUniformValue(
const char *name,
const QColor& color);
276 void setUniformValue(
const char *name,
const QPoint& point);
277 void setUniformValue(
const char *name,
const QPointF& point);
278 void setUniformValue(
const char *name,
const QSize& size);
279 void setUniformValue(
const char *name,
const QSizeF& size);
280 void setUniformValue(
const char *name,
const QMatrix2x2& value);
281 void setUniformValue(
const char *name,
const QMatrix2x3& value);
282 void setUniformValue(
const char *name,
const QMatrix2x4& value);
283 void setUniformValue(
const char *name,
const QMatrix3x2& value);
284 void setUniformValue(
const char *name,
const QMatrix3x3& value);
285 void setUniformValue(
const char *name,
const QMatrix3x4& value);
286 void setUniformValue(
const char *name,
const QMatrix4x2& value);
287 void setUniformValue(
const char *name,
const QMatrix4x3& value);
288 void setUniformValue(
const char *name,
const QMatrix4x4& value);
289 void setUniformValue(
const char *name,
const GLfloat value[2][2]);
290 void setUniformValue(
const char *name,
const GLfloat value[3][3]);
291 void setUniformValue(
const char *name,
const GLfloat value[4][4]);
292 void setUniformValue(
const char *name,
const QTransform& value);
294 void setUniformValueArray(
int location,
const GLfloat *values,
int count,
int tupleSize);
295 void setUniformValueArray(
int location,
const GLint *values,
int count);
296 void setUniformValueArray(
int location,
const GLuint *values,
int count);
297 void setUniformValueArray(
int location,
const QVector2D *values,
int count);
298 void setUniformValueArray(
int location,
const QVector3D *values,
int count);
299 void setUniformValueArray(
int location,
const QVector4D *values,
int count);
300 void setUniformValueArray(
int location,
const QMatrix2x2 *values,
int count);
301 void setUniformValueArray(
int location,
const QMatrix2x3 *values,
int count);
302 void setUniformValueArray(
int location,
const QMatrix2x4 *values,
int count);
303 void setUniformValueArray(
int location,
const QMatrix3x2 *values,
int count);
304 void setUniformValueArray(
int location,
const QMatrix3x3 *values,
int count);
305 void setUniformValueArray(
int location,
const QMatrix3x4 *values,
int count);
306 void setUniformValueArray(
int location,
const QMatrix4x2 *values,
int count);
307 void setUniformValueArray(
int location,
const QMatrix4x3 *values,
int count);
308 void setUniformValueArray(
int location,
const QMatrix4x4 *values,
int count);
310 void setUniformValueArray(
const char *name,
const GLfloat *values,
int count,
int tupleSize);
311 void setUniformValueArray(
const char *name,
const GLint *values,
int count);
312 void setUniformValueArray(
const char *name,
const GLuint *values,
int count);
313 void setUniformValueArray(
const char *name,
const QVector2D *values,
int count);
314 void setUniformValueArray(
const char *name,
const QVector3D *values,
int count);
315 void setUniformValueArray(
const char *name,
const QVector4D *values,
int count);
316 void setUniformValueArray(
const char *name,
const QMatrix2x2 *values,
int count);
317 void setUniformValueArray(
const char *name,
const QMatrix2x3 *values,
int count);
318 void setUniformValueArray(
const char *name,
const QMatrix2x4 *values,
int count);
319 void setUniformValueArray(
const char *name,
const QMatrix3x2 *values,
int count);
320 void setUniformValueArray(
const char *name,
const QMatrix3x3 *values,
int count);
321 void setUniformValueArray(
const char *name,
const QMatrix3x4 *values,
int count);
322 void setUniformValueArray(
const char *name,
const QMatrix4x2 *values,
int count);
323 void setUniformValueArray(
const char *name,
const QMatrix4x3 *values,
int count);
324 void setUniformValueArray(
const char *name,
const QMatrix4x4 *values,
int count);
326 static bool hasOpenGLShaderPrograms(
const QGLContext *context = 0);
329 void shaderDestroyed();
332 Q_DISABLE_COPY(QGLShaderProgram)
333 Q_DECLARE_PRIVATE(QGLShaderProgram)
GLuint GLuint GLsizei GLenum type
GLsizei GLsizei GLchar * source
#define QT_BEGIN_NAMESPACE
typedef GLenum(APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target)
typedef GLuint(APIENTRYP PFNGLCREATEPROGRAMPROC)()
GLuint GLuint GLsizei count
GLsizei const GLfloat * value
GLuint const GLchar * name
typedef GLint(APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program
GLubyte GLubyte GLubyte GLubyte w
GLboolean GLenum GLenum GLvoid * values