author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
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 |
#include "qglshaderprogram.h" |
|
43 |
#include "qglextensions_p.h" |
|
44 |
#include "qgl_p.h" |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
45 |
#include <QtCore/private/qobject_p.h> |
0 | 46 |
#include <QtCore/qdebug.h> |
47 |
#include <QtCore/qfile.h> |
|
48 |
#include <QtCore/qvarlengtharray.h> |
|
49 |
#include <QtCore/qvector.h> |
|
50 |
||
51 |
QT_BEGIN_NAMESPACE |
|
52 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
53 |
#if !defined(QT_OPENGL_ES_1) |
0 | 54 |
|
55 |
/*! |
|
56 |
\class QGLShaderProgram |
|
57 |
\brief The QGLShaderProgram class allows OpenGL shader programs to be linked and used. |
|
58 |
\since 4.6 |
|
59 |
\ingroup painting-3D |
|
60 |
||
61 |
\section1 Introduction |
|
62 |
||
63 |
This class supports shader programs written in the OpenGL Shading |
|
64 |
Language (GLSL) and in the OpenGL/ES Shading Language (GLSL/ES). |
|
65 |
||
66 |
QGLShader and QGLShaderProgram shelter the programmer from the details of |
|
67 |
compiling and linking vertex and fragment shaders. |
|
68 |
||
69 |
The following example creates a vertex shader program using the |
|
70 |
supplied source \c{code}. Once compiled and linked, the shader |
|
71 |
program is activated in the current QGLContext by calling |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
72 |
QGLShaderProgram::bind(): |
0 | 73 |
|
74 |
\snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 0 |
|
75 |
||
76 |
\section1 Writing portable shaders |
|
77 |
||
78 |
Shader programs can be difficult to reuse across OpenGL implementations |
|
79 |
because of varying levels of support for standard vertex attributes and |
|
80 |
uniform variables. In particular, GLSL/ES lacks all of the |
|
81 |
standard variables that are present on desktop OpenGL systems: |
|
82 |
\c{gl_Vertex}, \c{gl_Normal}, \c{gl_Color}, and so on. Desktop OpenGL |
|
83 |
lacks the variable qualifiers \c{highp}, \c{mediump}, and \c{lowp}. |
|
84 |
||
85 |
The QGLShaderProgram class makes the process of writing portable shaders |
|
86 |
easier by prefixing all shader programs with the following lines on |
|
87 |
desktop OpenGL: |
|
88 |
||
89 |
\code |
|
90 |
#define highp |
|
91 |
#define mediump |
|
92 |
#define lowp |
|
93 |
\endcode |
|
94 |
||
95 |
This makes it possible to run most GLSL/ES shader programs |
|
96 |
on desktop systems. The programmer should restrict themselves |
|
97 |
to just features that are present in GLSL/ES, and avoid |
|
98 |
standard variable names that only work on the desktop. |
|
99 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
100 |
If the \c{GL_ARB_ES2_compatibility} extension is present, |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
101 |
then the above prefix is not added because the desktop OpenGL |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
102 |
implementation supports precision qualifiers. |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
103 |
|
0 | 104 |
\section1 Simple shader example |
105 |
||
106 |
\snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 1 |
|
107 |
||
108 |
With the above shader program active, we can draw a green triangle |
|
109 |
as follows: |
|
110 |
||
111 |
\snippet doc/src/snippets/code/src_opengl_qglshaderprogram.cpp 2 |
|
112 |
||
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
113 |
\section1 Binary shaders and programs |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
114 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
115 |
Binary shaders may be specified using \c{glShaderBinary()} on |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
116 |
the return value from QGLShader::shaderId(). The QGLShader instance |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
117 |
containing the binary can then be added to the shader program with |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
118 |
addShader() and linked in the usual fashion with link(). |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
119 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
120 |
Binary programs may be specified using \c{glProgramBinaryOES()} |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
121 |
on the return value from programId(). Then the application should |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
122 |
call link(), which will notice that the program has already been |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
123 |
specified and linked, allowing other operations to be performed |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
124 |
on the shader program. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
125 |
|
0 | 126 |
\sa QGLShader |
127 |
*/ |
|
128 |
||
129 |
/*! |
|
130 |
\class QGLShader |
|
131 |
\brief The QGLShader class allows OpenGL shaders to be compiled. |
|
132 |
\since 4.6 |
|
133 |
\ingroup painting-3D |
|
134 |
||
135 |
This class supports shaders written in the OpenGL Shading Language (GLSL) |
|
136 |
and in the OpenGL/ES Shading Language (GLSL/ES). |
|
137 |
||
138 |
QGLShader and QGLShaderProgram shelter the programmer from the details of |
|
139 |
compiling and linking vertex and fragment shaders. |
|
140 |
||
141 |
\sa QGLShaderProgram |
|
142 |
*/ |
|
143 |
||
144 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
\enum QGLShader::ShaderTypeBit |
0 | 146 |
This enum specifies the type of QGLShader that is being created. |
147 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
\value Vertex Vertex shader written in the OpenGL Shading Language (GLSL). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
\value Fragment Fragment shader written in the OpenGL Shading Language (GLSL). |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
150 |
\value Geometry Geometry shaders written in the OpenGL Shading |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
151 |
Language (GLSL), based on the GL_EXT_geometry_shader4 extension. |
0 | 152 |
*/ |
153 |
||
154 |
#ifndef GL_FRAGMENT_SHADER |
|
155 |
#define GL_FRAGMENT_SHADER 0x8B30 |
|
156 |
#endif |
|
157 |
#ifndef GL_VERTEX_SHADER |
|
158 |
#define GL_VERTEX_SHADER 0x8B31 |
|
159 |
#endif |
|
160 |
#ifndef GL_COMPILE_STATUS |
|
161 |
#define GL_COMPILE_STATUS 0x8B81 |
|
162 |
#endif |
|
163 |
#ifndef GL_LINK_STATUS |
|
164 |
#define GL_LINK_STATUS 0x8B82 |
|
165 |
#endif |
|
166 |
#ifndef GL_INFO_LOG_LENGTH |
|
167 |
#define GL_INFO_LOG_LENGTH 0x8B84 |
|
168 |
#endif |
|
169 |
#ifndef GL_ACTIVE_UNIFORMS |
|
170 |
#define GL_ACTIVE_UNIFORMS 0x8B86 |
|
171 |
#endif |
|
172 |
#ifndef GL_ACTIVE_UNIFORM_MAX_LENGTH |
|
173 |
#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 |
|
174 |
#endif |
|
175 |
#ifndef GL_ACTIVE_ATTRIBUTES |
|
176 |
#define GL_ACTIVE_ATTRIBUTES 0x8B89 |
|
177 |
#endif |
|
178 |
#ifndef GL_ACTIVE_ATTRIBUTE_MAX_LENGTH |
|
179 |
#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A |
|
180 |
#endif |
|
181 |
#ifndef GL_CURRENT_VERTEX_ATTRIB |
|
182 |
#define GL_CURRENT_VERTEX_ATTRIB 0x8626 |
|
183 |
#endif |
|
184 |
#ifndef GL_SHADER_SOURCE_LENGTH |
|
185 |
#define GL_SHADER_SOURCE_LENGTH 0x8B88 |
|
186 |
#endif |
|
187 |
#ifndef GL_SHADER_BINARY_FORMATS |
|
188 |
#define GL_SHADER_BINARY_FORMATS 0x8DF8 |
|
189 |
#endif |
|
190 |
#ifndef GL_NUM_SHADER_BINARY_FORMATS |
|
191 |
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 |
|
192 |
#endif |
|
193 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
194 |
class QGLShaderPrivate : public QObjectPrivate |
0 | 195 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
196 |
Q_DECLARE_PUBLIC(QGLShader) |
0 | 197 |
public: |
198 |
QGLShaderPrivate(const QGLContext *context, QGLShader::ShaderType type) |
|
199 |
: shaderGuard(context) |
|
200 |
, shaderType(type) |
|
201 |
, compiled(false) |
|
202 |
{ |
|
203 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
~QGLShaderPrivate(); |
0 | 205 |
|
206 |
QGLSharedResourceGuard shaderGuard; |
|
207 |
QGLShader::ShaderType shaderType; |
|
208 |
bool compiled; |
|
209 |
QString log; |
|
210 |
||
211 |
bool create(); |
|
212 |
bool compile(QGLShader *q); |
|
213 |
void deleteShader(); |
|
214 |
}; |
|
215 |
||
216 |
#define ctx shaderGuard.context() |
|
217 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
QGLShaderPrivate::~QGLShaderPrivate() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
219 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
220 |
if (shaderGuard.id()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
221 |
QGLShareContextScope scope(shaderGuard.context()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
222 |
glDeleteShader(shaderGuard.id()); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
223 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
224 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
225 |
|
0 | 226 |
bool QGLShaderPrivate::create() |
227 |
{ |
|
228 |
const QGLContext *context = shaderGuard.context(); |
|
229 |
if (!context) |
|
230 |
return false; |
|
231 |
if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { |
|
232 |
GLuint shader; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
if (shaderType == QGLShader::Vertex) |
0 | 234 |
shader = glCreateShader(GL_VERTEX_SHADER); |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
235 |
else if (shaderType == QGLShader::Geometry) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
236 |
shader = glCreateShader(GL_GEOMETRY_SHADER_EXT); |
0 | 237 |
else |
238 |
shader = glCreateShader(GL_FRAGMENT_SHADER); |
|
239 |
if (!shader) { |
|
240 |
qWarning() << "QGLShader: could not create shader"; |
|
241 |
return false; |
|
242 |
} |
|
243 |
shaderGuard.setId(shader); |
|
244 |
return true; |
|
245 |
} else { |
|
246 |
return false; |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
bool QGLShaderPrivate::compile(QGLShader *q) |
|
251 |
{ |
|
252 |
GLuint shader = shaderGuard.id(); |
|
253 |
if (!shader) |
|
254 |
return false; |
|
255 |
glCompileShader(shader); |
|
256 |
GLint value = 0; |
|
257 |
glGetShaderiv(shader, GL_COMPILE_STATUS, &value); |
|
258 |
compiled = (value != 0); |
|
259 |
value = 0; |
|
260 |
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &value); |
|
261 |
if (!compiled && value > 1) { |
|
262 |
char *logbuf = new char [value]; |
|
263 |
GLint len; |
|
264 |
glGetShaderInfoLog(shader, value, &len, logbuf); |
|
265 |
log = QString::fromLatin1(logbuf); |
|
266 |
QString name = q->objectName(); |
|
267 |
if (name.isEmpty()) |
|
268 |
qWarning() << "QGLShader::compile:" << log; |
|
269 |
else |
|
270 |
qWarning() << "QGLShader::compile[" << name << "]:" << log; |
|
271 |
delete [] logbuf; |
|
272 |
} |
|
273 |
return compiled; |
|
274 |
} |
|
275 |
||
276 |
void QGLShaderPrivate::deleteShader() |
|
277 |
{ |
|
278 |
if (shaderGuard.id()) { |
|
279 |
glDeleteShader(shaderGuard.id()); |
|
280 |
shaderGuard.setId(0); |
|
281 |
} |
|
282 |
} |
|
283 |
||
284 |
#undef ctx |
|
285 |
#define ctx d->shaderGuard.context() |
|
286 |
||
287 |
/*! |
|
288 |
Constructs a new QGLShader object of the specified \a type |
|
289 |
and attaches it to \a parent. If shader programs are not supported, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
QGLShaderProgram::hasOpenGLShaderPrograms() will return false. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
This constructor is normally followed by a call to compileSourceCode() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
or compileSourceFile(). |
0 | 294 |
|
295 |
The shader will be associated with the current QGLContext. |
|
296 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
\sa compileSourceCode(), compileSourceFile() |
0 | 298 |
*/ |
299 |
QGLShader::QGLShader(QGLShader::ShaderType type, QObject *parent) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
: QObject(*new QGLShaderPrivate(QGLContext::currentContext(), type), parent) |
0 | 301 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
Q_D(QGLShader); |
0 | 303 |
d->create(); |
304 |
} |
|
305 |
||
306 |
/*! |
|
307 |
Constructs a new QGLShader object of the specified \a type |
|
308 |
and attaches it to \a parent. If shader programs are not supported, |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
then QGLShaderProgram::hasOpenGLShaderPrograms() will return false. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
This constructor is normally followed by a call to compileSourceCode() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
312 |
or compileSourceFile(). |
0 | 313 |
|
314 |
The shader will be associated with \a context. |
|
315 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
\sa compileSourceCode(), compileSourceFile() |
0 | 317 |
*/ |
318 |
QGLShader::QGLShader(QGLShader::ShaderType type, const QGLContext *context, QObject *parent) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
319 |
: QObject(*new QGLShaderPrivate(context ? context : QGLContext::currentContext(), type), parent) |
0 | 320 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
321 |
Q_D(QGLShader); |
0 | 322 |
#ifndef QT_NO_DEBUG |
323 |
if (context && !QGLContext::areSharing(context, QGLContext::currentContext())) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
324 |
qWarning("QGLShader::QGLShader: \'context\' must be the current context or sharing with it."); |
0 | 325 |
return; |
326 |
} |
|
327 |
#endif |
|
328 |
d->create(); |
|
329 |
} |
|
330 |
||
331 |
/*! |
|
332 |
Deletes this shader. If the shader has been attached to a |
|
333 |
QGLShaderProgram object, then the actual shader will stay around |
|
334 |
until the QGLShaderProgram is destroyed. |
|
335 |
*/ |
|
336 |
QGLShader::~QGLShader() |
|
337 |
{ |
|
338 |
} |
|
339 |
||
340 |
/*! |
|
341 |
Returns the type of this shader. |
|
342 |
*/ |
|
343 |
QGLShader::ShaderType QGLShader::shaderType() const |
|
344 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
345 |
Q_D(const QGLShader); |
0 | 346 |
return d->shaderType; |
347 |
} |
|
348 |
||
349 |
// The precision qualifiers are useful on OpenGL/ES systems, |
|
350 |
// but usually not present on desktop systems. Define the |
|
351 |
// keywords to empty strings on desktop systems. |
|
352 |
#ifndef QT_OPENGL_ES |
|
353 |
#define QGL_DEFINE_QUALIFIERS 1 |
|
354 |
static const char qualifierDefines[] = |
|
355 |
"#define lowp\n" |
|
356 |
"#define mediump\n" |
|
357 |
"#define highp\n"; |
|
358 |
#endif |
|
359 |
||
360 |
// The "highp" qualifier doesn't exist in fragment shaders |
|
361 |
// on all ES platforms. When it doesn't exist, use "mediump". |
|
362 |
#ifdef QT_OPENGL_ES |
|
363 |
#define QGL_REDEFINE_HIGHP 1 |
|
364 |
static const char redefineHighp[] = |
|
365 |
"#ifndef GL_FRAGMENT_PRECISION_HIGH\n" |
|
366 |
"#define highp mediump\n" |
|
367 |
"#endif\n"; |
|
368 |
#endif |
|
369 |
||
370 |
/*! |
|
371 |
Sets the \a source code for this shader and compiles it. |
|
372 |
Returns true if the source was successfully compiled, false otherwise. |
|
373 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
\sa compileSourceFile() |
0 | 375 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
376 |
bool QGLShader::compileSourceCode(const char *source) |
0 | 377 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
Q_D(QGLShader); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
379 |
if (d->shaderGuard.id()) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
380 |
QVarLengthArray<const char *, 4> src; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
381 |
QVarLengthArray<GLint, 4> srclen; |
0 | 382 |
int headerLen = 0; |
383 |
while (source && source[headerLen] == '#') { |
|
384 |
// Skip #version and #extension directives at the start of |
|
385 |
// the shader code. We need to insert the qualifierDefines |
|
386 |
// and redefineHighp just after them. |
|
387 |
if (qstrncmp(source + headerLen, "#version", 8) != 0 && |
|
388 |
qstrncmp(source + headerLen, "#extension", 10) != 0) { |
|
389 |
break; |
|
390 |
} |
|
391 |
while (source[headerLen] != '\0' && source[headerLen] != '\n') |
|
392 |
++headerLen; |
|
393 |
if (source[headerLen] == '\n') |
|
394 |
++headerLen; |
|
395 |
} |
|
396 |
if (headerLen > 0) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
397 |
src.append(source); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
srclen.append(GLint(headerLen)); |
0 | 399 |
} |
400 |
#ifdef QGL_DEFINE_QUALIFIERS |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
401 |
if (!(QGLExtensions::glExtensions() & QGLExtensions::ES2Compatibility)) { |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
402 |
src.append(qualifierDefines); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
403 |
srclen.append(GLint(sizeof(qualifierDefines) - 1)); |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
404 |
} |
0 | 405 |
#endif |
406 |
#ifdef QGL_REDEFINE_HIGHP |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
407 |
if (d->shaderType == Fragment) { |
0 | 408 |
src.append(redefineHighp); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
409 |
srclen.append(GLint(sizeof(redefineHighp) - 1)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
410 |
} |
0 | 411 |
#endif |
412 |
src.append(source + headerLen); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
413 |
srclen.append(GLint(qstrlen(source + headerLen))); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
414 |
glShaderSource(d->shaderGuard.id(), src.size(), src.data(), srclen.data()); |
0 | 415 |
return d->compile(this); |
416 |
} else { |
|
417 |
return false; |
|
418 |
} |
|
419 |
} |
|
420 |
||
421 |
/*! |
|
422 |
\overload |
|
423 |
||
424 |
Sets the \a source code for this shader and compiles it. |
|
425 |
Returns true if the source was successfully compiled, false otherwise. |
|
426 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
427 |
\sa compileSourceFile() |
0 | 428 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
429 |
bool QGLShader::compileSourceCode(const QByteArray& source) |
0 | 430 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
431 |
return compileSourceCode(source.constData()); |
0 | 432 |
} |
433 |
||
434 |
/*! |
|
435 |
\overload |
|
436 |
||
437 |
Sets the \a source code for this shader and compiles it. |
|
438 |
Returns true if the source was successfully compiled, false otherwise. |
|
439 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
440 |
\sa compileSourceFile() |
0 | 441 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
442 |
bool QGLShader::compileSourceCode(const QString& source) |
0 | 443 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
444 |
return compileSourceCode(source.toLatin1().constData()); |
0 | 445 |
} |
446 |
||
447 |
/*! |
|
448 |
Sets the source code for this shader to the contents of \a fileName |
|
449 |
and compiles it. Returns true if the file could be opened and the |
|
450 |
source compiled, false otherwise. |
|
451 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
452 |
\sa compileSourceCode() |
0 | 453 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
454 |
bool QGLShader::compileSourceFile(const QString& fileName) |
0 | 455 |
{ |
456 |
QFile file(fileName); |
|
457 |
if (!file.open(QFile::ReadOnly)) { |
|
458 |
qWarning() << "QGLShader: Unable to open file" << fileName; |
|
459 |
return false; |
|
460 |
} |
|
461 |
||
462 |
QByteArray contents = file.readAll(); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
return compileSourceCode(contents.constData()); |
0 | 464 |
} |
465 |
||
466 |
/*! |
|
467 |
Returns the source code for this shader. |
|
468 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
469 |
\sa compileSourceCode() |
0 | 470 |
*/ |
471 |
QByteArray QGLShader::sourceCode() const |
|
472 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
473 |
Q_D(const QGLShader); |
0 | 474 |
GLuint shader = d->shaderGuard.id(); |
475 |
if (!shader) |
|
476 |
return QByteArray(); |
|
477 |
GLint size = 0; |
|
478 |
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &size); |
|
479 |
if (size <= 0) |
|
480 |
return QByteArray(); |
|
481 |
GLint len = 0; |
|
482 |
char *source = new char [size]; |
|
483 |
glGetShaderSource(shader, size, &len, source); |
|
484 |
QByteArray src(source); |
|
485 |
delete [] source; |
|
486 |
return src; |
|
487 |
} |
|
488 |
||
489 |
/*! |
|
490 |
Returns true if this shader has been compiled; false otherwise. |
|
491 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
492 |
\sa compileSourceCode(), compileSourceFile() |
0 | 493 |
*/ |
494 |
bool QGLShader::isCompiled() const |
|
495 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
496 |
Q_D(const QGLShader); |
0 | 497 |
return d->compiled; |
498 |
} |
|
499 |
||
500 |
/*! |
|
501 |
Returns the errors and warnings that occurred during the last compile. |
|
502 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
503 |
\sa compileSourceCode(), compileSourceFile() |
0 | 504 |
*/ |
505 |
QString QGLShader::log() const |
|
506 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
507 |
Q_D(const QGLShader); |
0 | 508 |
return d->log; |
509 |
} |
|
510 |
||
511 |
/*! |
|
512 |
Returns the OpenGL identifier associated with this shader. |
|
513 |
||
514 |
\sa QGLShaderProgram::programId() |
|
515 |
*/ |
|
516 |
GLuint QGLShader::shaderId() const |
|
517 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
518 |
Q_D(const QGLShader); |
0 | 519 |
return d->shaderGuard.id(); |
520 |
} |
|
521 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
522 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
523 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
524 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
525 |
|
0 | 526 |
#undef ctx |
527 |
#define ctx programGuard.context() |
|
528 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
529 |
class QGLShaderProgramPrivate : public QObjectPrivate |
0 | 530 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
531 |
Q_DECLARE_PUBLIC(QGLShaderProgram) |
0 | 532 |
public: |
533 |
QGLShaderProgramPrivate(const QGLContext *context) |
|
534 |
: programGuard(context) |
|
535 |
, linked(false) |
|
536 |
, inited(false) |
|
537 |
, removingShaders(false) |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
538 |
, geometryVertexCount(64) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
539 |
, geometryInputType(0) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
540 |
, geometryOutputType(0) |
0 | 541 |
{ |
542 |
} |
|
543 |
~QGLShaderProgramPrivate(); |
|
544 |
||
545 |
QGLSharedResourceGuard programGuard; |
|
546 |
bool linked; |
|
547 |
bool inited; |
|
548 |
bool removingShaders; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
549 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
550 |
int geometryVertexCount; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
551 |
GLenum geometryInputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
552 |
GLenum geometryOutputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
553 |
|
0 | 554 |
QString log; |
555 |
QList<QGLShader *> shaders; |
|
556 |
QList<QGLShader *> anonShaders; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
557 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
558 |
bool hasShader(QGLShader::ShaderType type) const; |
0 | 559 |
}; |
560 |
||
561 |
QGLShaderProgramPrivate::~QGLShaderProgramPrivate() |
|
562 |
{ |
|
563 |
if (programGuard.id()) { |
|
564 |
QGLShareContextScope scope(programGuard.context()); |
|
565 |
glDeleteProgram(programGuard.id()); |
|
566 |
} |
|
567 |
} |
|
568 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
569 |
bool QGLShaderProgramPrivate::hasShader(QGLShader::ShaderType type) const |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
570 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
571 |
foreach (QGLShader *shader, shaders) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
572 |
if (shader->shaderType() == type) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
573 |
return true; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
574 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
575 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
576 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
577 |
|
0 | 578 |
#undef ctx |
579 |
#define ctx d->programGuard.context() |
|
580 |
||
581 |
/*! |
|
582 |
Constructs a new shader program and attaches it to \a parent. |
|
583 |
The program will be invalid until addShader() is called. |
|
584 |
||
585 |
The shader program will be associated with the current QGLContext. |
|
586 |
||
587 |
\sa addShader() |
|
588 |
*/ |
|
589 |
QGLShaderProgram::QGLShaderProgram(QObject *parent) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
590 |
: QObject(*new QGLShaderProgramPrivate(QGLContext::currentContext()), parent) |
0 | 591 |
{ |
592 |
} |
|
593 |
||
594 |
/*! |
|
595 |
Constructs a new shader program and attaches it to \a parent. |
|
596 |
The program will be invalid until addShader() is called. |
|
597 |
||
598 |
The shader program will be associated with \a context. |
|
599 |
||
600 |
\sa addShader() |
|
601 |
*/ |
|
602 |
QGLShaderProgram::QGLShaderProgram(const QGLContext *context, QObject *parent) |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
603 |
: QObject(*new QGLShaderProgramPrivate(context), parent) |
0 | 604 |
{ |
605 |
} |
|
606 |
||
607 |
/*! |
|
608 |
Deletes this shader program. |
|
609 |
*/ |
|
610 |
QGLShaderProgram::~QGLShaderProgram() |
|
611 |
{ |
|
612 |
} |
|
613 |
||
614 |
bool QGLShaderProgram::init() |
|
615 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
616 |
Q_D(QGLShaderProgram); |
0 | 617 |
if (d->programGuard.id() || d->inited) |
618 |
return true; |
|
619 |
d->inited = true; |
|
620 |
const QGLContext *context = d->programGuard.context(); |
|
621 |
if (!context) { |
|
622 |
context = QGLContext::currentContext(); |
|
623 |
d->programGuard.setContext(context); |
|
624 |
} |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
625 |
|
0 | 626 |
if (!context) |
627 |
return false; |
|
628 |
if (qt_resolve_glsl_extensions(const_cast<QGLContext *>(context))) { |
|
629 |
GLuint program = glCreateProgram(); |
|
630 |
if (!program) { |
|
631 |
qWarning() << "QGLShaderProgram: could not create shader program"; |
|
632 |
return false; |
|
633 |
} |
|
634 |
d->programGuard.setId(program); |
|
635 |
return true; |
|
636 |
} else { |
|
637 |
qWarning() << "QGLShaderProgram: shader programs are not supported"; |
|
638 |
return false; |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
/*! |
|
643 |
Adds a compiled \a shader to this shader program. Returns true |
|
644 |
if the shader could be added, or false otherwise. |
|
645 |
||
646 |
Ownership of the \a shader object remains with the caller. |
|
647 |
It will not be deleted when this QGLShaderProgram instance |
|
648 |
is deleted. This allows the caller to add the same shader |
|
649 |
to multiple shader programs. |
|
650 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
651 |
\sa addShaderFromSourceCode(), addShaderFromSourceFile() |
0 | 652 |
\sa removeShader(), link(), removeAllShaders() |
653 |
*/ |
|
654 |
bool QGLShaderProgram::addShader(QGLShader *shader) |
|
655 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
656 |
Q_D(QGLShaderProgram); |
0 | 657 |
if (!init()) |
658 |
return false; |
|
659 |
if (d->shaders.contains(shader)) |
|
660 |
return true; // Already added to this shader program. |
|
661 |
if (d->programGuard.id() && shader) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
662 |
if (!QGLContext::areSharing(shader->d_func()->shaderGuard.context(), |
0 | 663 |
d->programGuard.context())) { |
664 |
qWarning("QGLShaderProgram::addShader: Program and shader are not associated with same context."); |
|
665 |
return false; |
|
666 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
if (!shader->d_func()->shaderGuard.id()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
669 |
glAttachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); |
0 | 670 |
d->linked = false; // Program needs to be relinked. |
671 |
d->shaders.append(shader); |
|
672 |
connect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); |
|
673 |
return true; |
|
674 |
} else { |
|
675 |
return false; |
|
676 |
} |
|
677 |
} |
|
678 |
||
679 |
/*! |
|
680 |
Compiles \a source as a shader of the specified \a type and |
|
681 |
adds it to this shader program. Returns true if compilation |
|
682 |
was successful, false otherwise. The compilation errors |
|
683 |
and warnings will be made available via log(). |
|
684 |
||
685 |
This function is intended to be a short-cut for quickly |
|
686 |
adding vertex and fragment shaders to a shader program without |
|
687 |
creating an instance of QGLShader first. |
|
688 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
689 |
\sa addShader(), addShaderFromSourceFile() |
0 | 690 |
\sa removeShader(), link(), log(), removeAllShaders() |
691 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
692 |
bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const char *source) |
0 | 693 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
694 |
Q_D(QGLShaderProgram); |
0 | 695 |
if (!init()) |
696 |
return false; |
|
697 |
QGLShader *shader = new QGLShader(type, this); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
698 |
if (!shader->compileSourceCode(source)) { |
0 | 699 |
d->log = shader->log(); |
700 |
delete shader; |
|
701 |
return false; |
|
702 |
} |
|
703 |
d->anonShaders.append(shader); |
|
704 |
return addShader(shader); |
|
705 |
} |
|
706 |
||
707 |
/*! |
|
708 |
\overload |
|
709 |
||
710 |
Compiles \a source as a shader of the specified \a type and |
|
711 |
adds it to this shader program. Returns true if compilation |
|
712 |
was successful, false otherwise. The compilation errors |
|
713 |
and warnings will be made available via log(). |
|
714 |
||
715 |
This function is intended to be a short-cut for quickly |
|
716 |
adding vertex and fragment shaders to a shader program without |
|
717 |
creating an instance of QGLShader first. |
|
718 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
719 |
\sa addShader(), addShaderFromSourceFile() |
0 | 720 |
\sa removeShader(), link(), log(), removeAllShaders() |
721 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
722 |
bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QByteArray& source) |
0 | 723 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
return addShaderFromSourceCode(type, source.constData()); |
0 | 725 |
} |
726 |
||
727 |
/*! |
|
728 |
\overload |
|
729 |
||
730 |
Compiles \a source as a shader of the specified \a type and |
|
731 |
adds it to this shader program. Returns true if compilation |
|
732 |
was successful, false otherwise. The compilation errors |
|
733 |
and warnings will be made available via log(). |
|
734 |
||
735 |
This function is intended to be a short-cut for quickly |
|
736 |
adding vertex and fragment shaders to a shader program without |
|
737 |
creating an instance of QGLShader first. |
|
738 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
739 |
\sa addShader(), addShaderFromSourceFile() |
0 | 740 |
\sa removeShader(), link(), log(), removeAllShaders() |
741 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
742 |
bool QGLShaderProgram::addShaderFromSourceCode(QGLShader::ShaderType type, const QString& source) |
0 | 743 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
744 |
return addShaderFromSourceCode(type, source.toLatin1().constData()); |
0 | 745 |
} |
746 |
||
747 |
/*! |
|
748 |
Compiles the contents of \a fileName as a shader of the specified |
|
749 |
\a type and adds it to this shader program. Returns true if |
|
750 |
compilation was successful, false otherwise. The compilation errors |
|
751 |
and warnings will be made available via log(). |
|
752 |
||
753 |
This function is intended to be a short-cut for quickly |
|
754 |
adding vertex and fragment shaders to a shader program without |
|
755 |
creating an instance of QGLShader first. |
|
756 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
757 |
\sa addShader(), addShaderFromSourceCode() |
0 | 758 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
bool QGLShaderProgram::addShaderFromSourceFile |
0 | 760 |
(QGLShader::ShaderType type, const QString& fileName) |
761 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
Q_D(QGLShaderProgram); |
0 | 763 |
if (!init()) |
764 |
return false; |
|
765 |
QGLShader *shader = new QGLShader(type, this); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
766 |
if (!shader->compileSourceFile(fileName)) { |
0 | 767 |
d->log = shader->log(); |
768 |
delete shader; |
|
769 |
return false; |
|
770 |
} |
|
771 |
d->anonShaders.append(shader); |
|
772 |
return addShader(shader); |
|
773 |
} |
|
774 |
||
775 |
/*! |
|
776 |
Removes \a shader from this shader program. The object is not deleted. |
|
777 |
||
778 |
\sa addShader(), link(), removeAllShaders() |
|
779 |
*/ |
|
780 |
void QGLShaderProgram::removeShader(QGLShader *shader) |
|
781 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
782 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
783 |
if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) { |
0 | 784 |
QGLShareContextScope scope(d->programGuard.context()); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
785 |
glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); |
0 | 786 |
} |
787 |
d->linked = false; // Program needs to be relinked. |
|
788 |
if (shader) { |
|
789 |
d->shaders.removeAll(shader); |
|
790 |
d->anonShaders.removeAll(shader); |
|
791 |
disconnect(shader, SIGNAL(destroyed()), this, SLOT(shaderDestroyed())); |
|
792 |
} |
|
793 |
} |
|
794 |
||
795 |
/*! |
|
796 |
Returns a list of all shaders that have been added to this shader |
|
797 |
program using addShader(). |
|
798 |
||
799 |
\sa addShader(), removeShader() |
|
800 |
*/ |
|
801 |
QList<QGLShader *> QGLShaderProgram::shaders() const |
|
802 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
803 |
Q_D(const QGLShaderProgram); |
0 | 804 |
return d->shaders; |
805 |
} |
|
806 |
||
807 |
/*! |
|
808 |
Removes all of the shaders that were added to this program previously. |
|
809 |
The QGLShader objects for the shaders will not be deleted if they |
|
810 |
were constructed externally. QGLShader objects that are constructed |
|
811 |
internally by QGLShaderProgram will be deleted. |
|
812 |
||
813 |
\sa addShader(), removeShader() |
|
814 |
*/ |
|
815 |
void QGLShaderProgram::removeAllShaders() |
|
816 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
817 |
Q_D(QGLShaderProgram); |
0 | 818 |
d->removingShaders = true; |
819 |
foreach (QGLShader *shader, d->shaders) { |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
820 |
if (d->programGuard.id() && shader && shader->d_func()->shaderGuard.id()) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
821 |
glDetachShader(d->programGuard.id(), shader->d_func()->shaderGuard.id()); |
0 | 822 |
} |
823 |
foreach (QGLShader *shader, d->anonShaders) { |
|
824 |
// Delete shader objects that were created anonymously. |
|
825 |
delete shader; |
|
826 |
} |
|
827 |
d->shaders.clear(); |
|
828 |
d->anonShaders.clear(); |
|
829 |
d->linked = false; // Program needs to be relinked. |
|
830 |
d->removingShaders = false; |
|
831 |
} |
|
832 |
||
833 |
/*! |
|
834 |
Links together the shaders that were added to this program with |
|
835 |
addShader(). Returns true if the link was successful or |
|
836 |
false otherwise. If the link failed, the error messages can |
|
837 |
be retrieved with log(). |
|
838 |
||
839 |
Subclasses can override this function to initialize attributes |
|
840 |
and uniform variables for use in specific shader programs. |
|
841 |
||
842 |
If the shader program was already linked, calling this |
|
843 |
function again will force it to be re-linked. |
|
844 |
||
845 |
\sa addShader(), log() |
|
846 |
*/ |
|
847 |
bool QGLShaderProgram::link() |
|
848 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
849 |
Q_D(QGLShaderProgram); |
0 | 850 |
GLuint program = d->programGuard.id(); |
851 |
if (!program) |
|
852 |
return false; |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
853 |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
854 |
GLint value; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
855 |
if (d->shaders.isEmpty()) { |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
856 |
// If there are no explicit shaders, then it is possible that the |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
857 |
// application added a program binary with glProgramBinaryOES(), |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
858 |
// or otherwise populated the shaders itself. Check to see if the |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
859 |
// program is already linked and bail out if so. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
860 |
value = 0; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
861 |
glGetProgramiv(program, GL_LINK_STATUS, &value); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
862 |
d->linked = (value != 0); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
863 |
if (d->linked) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
864 |
return true; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
865 |
} |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
866 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
867 |
// Set up the geometry shader parameters |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
868 |
if (glProgramParameteriEXT) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
869 |
foreach (QGLShader *shader, d->shaders) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
870 |
if (shader->shaderType() & QGLShader::Geometry) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
871 |
glProgramParameteriEXT(program, GL_GEOMETRY_INPUT_TYPE_EXT, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
872 |
d->geometryInputType); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
873 |
glProgramParameteriEXT(program, GL_GEOMETRY_OUTPUT_TYPE_EXT, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
874 |
d->geometryOutputType); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
875 |
glProgramParameteriEXT(program, GL_GEOMETRY_VERTICES_OUT_EXT, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
876 |
d->geometryVertexCount); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
877 |
break; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
878 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
879 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
880 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
881 |
|
0 | 882 |
glLinkProgram(program); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
883 |
value = 0; |
0 | 884 |
glGetProgramiv(program, GL_LINK_STATUS, &value); |
885 |
d->linked = (value != 0); |
|
886 |
value = 0; |
|
887 |
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &value); |
|
888 |
d->log = QString(); |
|
889 |
if (value > 1) { |
|
890 |
char *logbuf = new char [value]; |
|
891 |
GLint len; |
|
892 |
glGetProgramInfoLog(program, value, &len, logbuf); |
|
893 |
d->log = QString::fromLatin1(logbuf); |
|
894 |
QString name = objectName(); |
|
895 |
if (name.isEmpty()) |
|
896 |
qWarning() << "QGLShader::link:" << d->log; |
|
897 |
else |
|
898 |
qWarning() << "QGLShader::link[" << name << "]:" << d->log; |
|
899 |
delete [] logbuf; |
|
900 |
} |
|
901 |
return d->linked; |
|
902 |
} |
|
903 |
||
904 |
/*! |
|
905 |
Returns true if this shader program has been linked; false otherwise. |
|
906 |
||
907 |
\sa link() |
|
908 |
*/ |
|
909 |
bool QGLShaderProgram::isLinked() const |
|
910 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
911 |
Q_D(const QGLShaderProgram); |
0 | 912 |
return d->linked; |
913 |
} |
|
914 |
||
915 |
/*! |
|
916 |
Returns the errors and warnings that occurred during the last link() |
|
917 |
or addShader() with explicitly specified source code. |
|
918 |
||
919 |
\sa link() |
|
920 |
*/ |
|
921 |
QString QGLShaderProgram::log() const |
|
922 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
Q_D(const QGLShaderProgram); |
0 | 924 |
return d->log; |
925 |
} |
|
926 |
||
927 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
928 |
Binds this shader program to the active QGLContext and makes |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
929 |
it the current shader program. Any previously bound shader program |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
930 |
is released. This is equivalent to calling \c{glUseProgram()} on |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
931 |
programId(). Returns true if the program was successfully bound; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
932 |
false otherwise. If the shader program has not yet been linked, |
0 | 933 |
or it needs to be re-linked, this function will call link(). |
934 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
935 |
\sa link(), release() |
0 | 936 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
937 |
bool QGLShaderProgram::bind() |
0 | 938 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
939 |
Q_D(QGLShaderProgram); |
0 | 940 |
GLuint program = d->programGuard.id(); |
941 |
if (!program) |
|
942 |
return false; |
|
943 |
if (!d->linked && !link()) |
|
944 |
return false; |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
945 |
#ifndef QT_NO_DEBUG |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
946 |
if (!QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())) { |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
947 |
qWarning("QGLShaderProgram::bind: program is not valid in the current context."); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
948 |
return false; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
949 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
950 |
#endif |
0 | 951 |
glUseProgram(program); |
952 |
return true; |
|
953 |
} |
|
954 |
||
955 |
#undef ctx |
|
956 |
#define ctx QGLContext::currentContext() |
|
957 |
||
958 |
/*! |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
959 |
Releases the active shader program from the current QGLContext. |
0 | 960 |
This is equivalent to calling \c{glUseProgram(0)}. |
961 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
962 |
\sa bind() |
0 | 963 |
*/ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
964 |
void QGLShaderProgram::release() |
0 | 965 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
966 |
#ifndef QT_NO_DEBUG |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
967 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
968 |
if (!QGLContext::areSharing(d->programGuard.context(), QGLContext::currentContext())) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
969 |
qWarning("QGLShaderProgram::release: program is not valid in the current context."); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
970 |
#endif |
0 | 971 |
#if defined(QT_OPENGL_ES_2) |
972 |
glUseProgram(0); |
|
973 |
#else |
|
974 |
if (glUseProgram) |
|
975 |
glUseProgram(0); |
|
976 |
#endif |
|
977 |
} |
|
978 |
||
979 |
#undef ctx |
|
980 |
#define ctx d->programGuard.context() |
|
981 |
||
982 |
/*! |
|
983 |
Returns the OpenGL identifier associated with this shader program. |
|
984 |
||
985 |
\sa QGLShader::shaderId() |
|
986 |
*/ |
|
987 |
GLuint QGLShaderProgram::programId() const |
|
988 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
989 |
Q_D(const QGLShaderProgram); |
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
990 |
GLuint id = d->programGuard.id(); |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
991 |
if (id) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
992 |
return id; |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
993 |
|
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
994 |
// Create the identifier if we don't have one yet. This is for |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
995 |
// applications that want to create the attached shader configuration |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
996 |
// themselves, particularly those using program binaries. |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
997 |
if (!const_cast<QGLShaderProgram *>(this)->init()) |
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
998 |
return 0; |
0 | 999 |
return d->programGuard.id(); |
1000 |
} |
|
1001 |
||
1002 |
/*! |
|
1003 |
Binds the attribute \a name to the specified \a location. This |
|
1004 |
function can be called before or after the program has been linked. |
|
1005 |
Any attributes that have not been explicitly bound when the program |
|
1006 |
is linked will be assigned locations automatically. |
|
1007 |
||
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1008 |
When this function is called after the program has been linked, |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1009 |
the program will need to be relinked for the change to take effect. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1010 |
|
0 | 1011 |
\sa attributeLocation() |
1012 |
*/ |
|
1013 |
void QGLShaderProgram::bindAttributeLocation(const char *name, int location) |
|
1014 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1015 |
Q_D(QGLShaderProgram); |
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1016 |
if (!init()) |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1017 |
return; |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1018 |
glBindAttribLocation(d->programGuard.id(), location, name); |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1019 |
d->linked = false; // Program needs to be relinked. |
0 | 1020 |
} |
1021 |
||
1022 |
/*! |
|
1023 |
\overload |
|
1024 |
||
1025 |
Binds the attribute \a name to the specified \a location. This |
|
1026 |
function can be called before or after the program has been linked. |
|
1027 |
Any attributes that have not been explicitly bound when the program |
|
1028 |
is linked will be assigned locations automatically. |
|
1029 |
||
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1030 |
When this function is called after the program has been linked, |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1031 |
the program will need to be relinked for the change to take effect. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1032 |
|
0 | 1033 |
\sa attributeLocation() |
1034 |
*/ |
|
1035 |
void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location) |
|
1036 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1037 |
bindAttributeLocation(name.constData(), location); |
0 | 1038 |
} |
1039 |
||
1040 |
/*! |
|
1041 |
\overload |
|
1042 |
||
1043 |
Binds the attribute \a name to the specified \a location. This |
|
1044 |
function can be called before or after the program has been linked. |
|
1045 |
Any attributes that have not been explicitly bound when the program |
|
1046 |
is linked will be assigned locations automatically. |
|
1047 |
||
22
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1048 |
When this function is called after the program has been linked, |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1049 |
the program will need to be relinked for the change to take effect. |
79de32ba3296
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
1050 |
|
0 | 1051 |
\sa attributeLocation() |
1052 |
*/ |
|
1053 |
void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) |
|
1054 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1055 |
bindAttributeLocation(name.toLatin1().constData(), location); |
0 | 1056 |
} |
1057 |
||
1058 |
/*! |
|
1059 |
Returns the location of the attribute \a name within this shader |
|
1060 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1061 |
attribute for this shader program. |
|
1062 |
||
1063 |
\sa uniformLocation(), bindAttributeLocation() |
|
1064 |
*/ |
|
1065 |
int QGLShaderProgram::attributeLocation(const char *name) const |
|
1066 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1067 |
Q_D(const QGLShaderProgram); |
0 | 1068 |
if (d->linked) { |
1069 |
return glGetAttribLocation(d->programGuard.id(), name); |
|
1070 |
} else { |
|
1071 |
qWarning() << "QGLShaderProgram::attributeLocation(" << name |
|
1072 |
<< "): shader program is not linked"; |
|
1073 |
return -1; |
|
1074 |
} |
|
1075 |
} |
|
1076 |
||
1077 |
/*! |
|
1078 |
\overload |
|
1079 |
||
1080 |
Returns the location of the attribute \a name within this shader |
|
1081 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1082 |
attribute for this shader program. |
|
1083 |
||
1084 |
\sa uniformLocation(), bindAttributeLocation() |
|
1085 |
*/ |
|
1086 |
int QGLShaderProgram::attributeLocation(const QByteArray& name) const |
|
1087 |
{ |
|
1088 |
return attributeLocation(name.constData()); |
|
1089 |
} |
|
1090 |
||
1091 |
/*! |
|
1092 |
\overload |
|
1093 |
||
1094 |
Returns the location of the attribute \a name within this shader |
|
1095 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1096 |
attribute for this shader program. |
|
1097 |
||
1098 |
\sa uniformLocation(), bindAttributeLocation() |
|
1099 |
*/ |
|
1100 |
int QGLShaderProgram::attributeLocation(const QString& name) const |
|
1101 |
{ |
|
1102 |
return attributeLocation(name.toLatin1().constData()); |
|
1103 |
} |
|
1104 |
||
1105 |
/*! |
|
1106 |
Sets the attribute at \a location in the current context to \a value. |
|
1107 |
||
1108 |
\sa setUniformValue() |
|
1109 |
*/ |
|
1110 |
void QGLShaderProgram::setAttributeValue(int location, GLfloat value) |
|
1111 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1112 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1113 |
Q_UNUSED(d); |
0 | 1114 |
if (location != -1) |
1115 |
glVertexAttrib1fv(location, &value); |
|
1116 |
} |
|
1117 |
||
1118 |
/*! |
|
1119 |
\overload |
|
1120 |
||
1121 |
Sets the attribute called \a name in the current context to \a value. |
|
1122 |
||
1123 |
\sa setUniformValue() |
|
1124 |
*/ |
|
1125 |
void QGLShaderProgram::setAttributeValue(const char *name, GLfloat value) |
|
1126 |
{ |
|
1127 |
setAttributeValue(attributeLocation(name), value); |
|
1128 |
} |
|
1129 |
||
1130 |
/*! |
|
1131 |
Sets the attribute at \a location in the current context to |
|
1132 |
the 2D vector (\a x, \a y). |
|
1133 |
||
1134 |
\sa setUniformValue() |
|
1135 |
*/ |
|
1136 |
void QGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y) |
|
1137 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1138 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1139 |
Q_UNUSED(d); |
0 | 1140 |
if (location != -1) { |
1141 |
GLfloat values[2] = {x, y}; |
|
1142 |
glVertexAttrib2fv(location, values); |
|
1143 |
} |
|
1144 |
} |
|
1145 |
||
1146 |
/*! |
|
1147 |
\overload |
|
1148 |
||
1149 |
Sets the attribute called \a name in the current context to |
|
1150 |
the 2D vector (\a x, \a y). |
|
1151 |
||
1152 |
\sa setUniformValue() |
|
1153 |
*/ |
|
1154 |
void QGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y) |
|
1155 |
{ |
|
1156 |
setAttributeValue(attributeLocation(name), x, y); |
|
1157 |
} |
|
1158 |
||
1159 |
/*! |
|
1160 |
Sets the attribute at \a location in the current context to |
|
1161 |
the 3D vector (\a x, \a y, \a z). |
|
1162 |
||
1163 |
\sa setUniformValue() |
|
1164 |
*/ |
|
1165 |
void QGLShaderProgram::setAttributeValue |
|
1166 |
(int location, GLfloat x, GLfloat y, GLfloat z) |
|
1167 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
Q_UNUSED(d); |
0 | 1170 |
if (location != -1) { |
1171 |
GLfloat values[3] = {x, y, z}; |
|
1172 |
glVertexAttrib3fv(location, values); |
|
1173 |
} |
|
1174 |
} |
|
1175 |
||
1176 |
/*! |
|
1177 |
\overload |
|
1178 |
||
1179 |
Sets the attribute called \a name in the current context to |
|
1180 |
the 3D vector (\a x, \a y, \a z). |
|
1181 |
||
1182 |
\sa setUniformValue() |
|
1183 |
*/ |
|
1184 |
void QGLShaderProgram::setAttributeValue |
|
1185 |
(const char *name, GLfloat x, GLfloat y, GLfloat z) |
|
1186 |
{ |
|
1187 |
setAttributeValue(attributeLocation(name), x, y, z); |
|
1188 |
} |
|
1189 |
||
1190 |
/*! |
|
1191 |
Sets the attribute at \a location in the current context to |
|
1192 |
the 4D vector (\a x, \a y, \a z, \a w). |
|
1193 |
||
1194 |
\sa setUniformValue() |
|
1195 |
*/ |
|
1196 |
void QGLShaderProgram::setAttributeValue |
|
1197 |
(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
|
1198 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1199 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1200 |
Q_UNUSED(d); |
0 | 1201 |
if (location != -1) { |
1202 |
GLfloat values[4] = {x, y, z, w}; |
|
1203 |
glVertexAttrib4fv(location, values); |
|
1204 |
} |
|
1205 |
} |
|
1206 |
||
1207 |
/*! |
|
1208 |
\overload |
|
1209 |
||
1210 |
Sets the attribute called \a name in the current context to |
|
1211 |
the 4D vector (\a x, \a y, \a z, \a w). |
|
1212 |
||
1213 |
\sa setUniformValue() |
|
1214 |
*/ |
|
1215 |
void QGLShaderProgram::setAttributeValue |
|
1216 |
(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
|
1217 |
{ |
|
1218 |
setAttributeValue(attributeLocation(name), x, y, z, w); |
|
1219 |
} |
|
1220 |
||
1221 |
/*! |
|
1222 |
Sets the attribute at \a location in the current context to \a value. |
|
1223 |
||
1224 |
\sa setUniformValue() |
|
1225 |
*/ |
|
1226 |
void QGLShaderProgram::setAttributeValue(int location, const QVector2D& value) |
|
1227 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1228 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1229 |
Q_UNUSED(d); |
0 | 1230 |
if (location != -1) |
1231 |
glVertexAttrib2fv(location, reinterpret_cast<const GLfloat *>(&value)); |
|
1232 |
} |
|
1233 |
||
1234 |
/*! |
|
1235 |
\overload |
|
1236 |
||
1237 |
Sets the attribute called \a name in the current context to \a value. |
|
1238 |
||
1239 |
\sa setUniformValue() |
|
1240 |
*/ |
|
1241 |
void QGLShaderProgram::setAttributeValue(const char *name, const QVector2D& value) |
|
1242 |
{ |
|
1243 |
setAttributeValue(attributeLocation(name), value); |
|
1244 |
} |
|
1245 |
||
1246 |
/*! |
|
1247 |
Sets the attribute at \a location in the current context to \a value. |
|
1248 |
||
1249 |
\sa setUniformValue() |
|
1250 |
*/ |
|
1251 |
void QGLShaderProgram::setAttributeValue(int location, const QVector3D& value) |
|
1252 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1253 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1254 |
Q_UNUSED(d); |
0 | 1255 |
if (location != -1) |
1256 |
glVertexAttrib3fv(location, reinterpret_cast<const GLfloat *>(&value)); |
|
1257 |
} |
|
1258 |
||
1259 |
/*! |
|
1260 |
\overload |
|
1261 |
||
1262 |
Sets the attribute called \a name in the current context to \a value. |
|
1263 |
||
1264 |
\sa setUniformValue() |
|
1265 |
*/ |
|
1266 |
void QGLShaderProgram::setAttributeValue(const char *name, const QVector3D& value) |
|
1267 |
{ |
|
1268 |
setAttributeValue(attributeLocation(name), value); |
|
1269 |
} |
|
1270 |
||
1271 |
/*! |
|
1272 |
Sets the attribute at \a location in the current context to \a value. |
|
1273 |
||
1274 |
\sa setUniformValue() |
|
1275 |
*/ |
|
1276 |
void QGLShaderProgram::setAttributeValue(int location, const QVector4D& value) |
|
1277 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1278 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1279 |
Q_UNUSED(d); |
0 | 1280 |
if (location != -1) |
1281 |
glVertexAttrib4fv(location, reinterpret_cast<const GLfloat *>(&value)); |
|
1282 |
} |
|
1283 |
||
1284 |
/*! |
|
1285 |
\overload |
|
1286 |
||
1287 |
Sets the attribute called \a name in the current context to \a value. |
|
1288 |
||
1289 |
\sa setUniformValue() |
|
1290 |
*/ |
|
1291 |
void QGLShaderProgram::setAttributeValue(const char *name, const QVector4D& value) |
|
1292 |
{ |
|
1293 |
setAttributeValue(attributeLocation(name), value); |
|
1294 |
} |
|
1295 |
||
1296 |
/*! |
|
1297 |
Sets the attribute at \a location in the current context to \a value. |
|
1298 |
||
1299 |
\sa setUniformValue() |
|
1300 |
*/ |
|
1301 |
void QGLShaderProgram::setAttributeValue(int location, const QColor& value) |
|
1302 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1303 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1304 |
Q_UNUSED(d); |
0 | 1305 |
if (location != -1) { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1306 |
GLfloat values[4] = {GLfloat(value.redF()), GLfloat(value.greenF()), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1307 |
GLfloat(value.blueF()), GLfloat(value.alphaF())}; |
0 | 1308 |
glVertexAttrib4fv(location, values); |
1309 |
} |
|
1310 |
} |
|
1311 |
||
1312 |
/*! |
|
1313 |
\overload |
|
1314 |
||
1315 |
Sets the attribute called \a name in the current context to \a value. |
|
1316 |
||
1317 |
\sa setUniformValue() |
|
1318 |
*/ |
|
1319 |
void QGLShaderProgram::setAttributeValue(const char *name, const QColor& value) |
|
1320 |
{ |
|
1321 |
setAttributeValue(attributeLocation(name), value); |
|
1322 |
} |
|
1323 |
||
1324 |
/*! |
|
1325 |
Sets the attribute at \a location in the current context to the |
|
1326 |
contents of \a values, which contains \a columns elements, each |
|
1327 |
consisting of \a rows elements. The \a rows value should be |
|
1328 |
1, 2, 3, or 4. This function is typically used to set matrix |
|
1329 |
values and column vectors. |
|
1330 |
||
1331 |
\sa setUniformValue() |
|
1332 |
*/ |
|
1333 |
void QGLShaderProgram::setAttributeValue |
|
1334 |
(int location, const GLfloat *values, int columns, int rows) |
|
1335 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1336 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1337 |
Q_UNUSED(d); |
0 | 1338 |
if (rows < 1 || rows > 4) { |
1339 |
qWarning() << "QGLShaderProgram::setAttributeValue: rows" << rows << "not supported"; |
|
1340 |
return; |
|
1341 |
} |
|
1342 |
if (location != -1) { |
|
1343 |
while (columns-- > 0) { |
|
1344 |
if (rows == 1) |
|
1345 |
glVertexAttrib1fv(location, values); |
|
1346 |
else if (rows == 2) |
|
1347 |
glVertexAttrib2fv(location, values); |
|
1348 |
else if (rows == 3) |
|
1349 |
glVertexAttrib3fv(location, values); |
|
1350 |
else |
|
1351 |
glVertexAttrib4fv(location, values); |
|
1352 |
values += rows; |
|
1353 |
++location; |
|
1354 |
} |
|
1355 |
} |
|
1356 |
} |
|
1357 |
||
1358 |
/*! |
|
1359 |
\overload |
|
1360 |
||
1361 |
Sets the attribute called \a name in the current context to the |
|
1362 |
contents of \a values, which contains \a columns elements, each |
|
1363 |
consisting of \a rows elements. The \a rows value should be |
|
1364 |
1, 2, 3, or 4. This function is typically used to set matrix |
|
1365 |
values and column vectors. |
|
1366 |
||
1367 |
\sa setUniformValue() |
|
1368 |
*/ |
|
1369 |
void QGLShaderProgram::setAttributeValue |
|
1370 |
(const char *name, const GLfloat *values, int columns, int rows) |
|
1371 |
{ |
|
1372 |
setAttributeValue(attributeLocation(name), values, columns, rows); |
|
1373 |
} |
|
1374 |
||
1375 |
/*! |
|
1376 |
Sets an array of vertex \a values on the attribute at \a location |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1377 |
in this shader program. The \a tupleSize indicates the number of |
0 | 1378 |
components per vertex (1, 2, 3, or 4), and the \a stride indicates |
1379 |
the number of bytes between vertices. A default \a stride value |
|
1380 |
of zero indicates that the vertices are densely packed in \a values. |
|
1381 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1382 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1383 |
on the \a location. Otherwise the value specified with |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1384 |
setAttributeValue() for \a location will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1385 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1386 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1387 |
\sa disableAttributeArray() |
0 | 1388 |
*/ |
1389 |
void QGLShaderProgram::setAttributeArray |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1390 |
(int location, const GLfloat *values, int tupleSize, int stride) |
0 | 1391 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1392 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1393 |
Q_UNUSED(d); |
0 | 1394 |
if (location != -1) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1395 |
glVertexAttribPointer(location, tupleSize, GL_FLOAT, GL_FALSE, |
0 | 1396 |
stride, values); |
1397 |
} |
|
1398 |
} |
|
1399 |
||
1400 |
/*! |
|
1401 |
Sets an array of 2D vertex \a values on the attribute at \a location |
|
1402 |
in this shader program. The \a stride indicates the number of bytes |
|
1403 |
between vertices. A default \a stride value of zero indicates that |
|
1404 |
the vertices are densely packed in \a values. |
|
1405 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1406 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1407 |
on the \a location. Otherwise the value specified with |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1408 |
setAttributeValue() for \a location will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1409 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1411 |
\sa disableAttributeArray() |
0 | 1412 |
*/ |
1413 |
void QGLShaderProgram::setAttributeArray |
|
1414 |
(int location, const QVector2D *values, int stride) |
|
1415 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
Q_UNUSED(d); |
0 | 1418 |
if (location != -1) { |
1419 |
glVertexAttribPointer(location, 2, GL_FLOAT, GL_FALSE, |
|
1420 |
stride, values); |
|
1421 |
} |
|
1422 |
} |
|
1423 |
||
1424 |
/*! |
|
1425 |
Sets an array of 3D vertex \a values on the attribute at \a location |
|
1426 |
in this shader program. The \a stride indicates the number of bytes |
|
1427 |
between vertices. A default \a stride value of zero indicates that |
|
1428 |
the vertices are densely packed in \a values. |
|
1429 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1430 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1431 |
on the \a location. Otherwise the value specified with |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1432 |
setAttributeValue() for \a location will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1433 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1434 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1435 |
\sa disableAttributeArray() |
0 | 1436 |
*/ |
1437 |
void QGLShaderProgram::setAttributeArray |
|
1438 |
(int location, const QVector3D *values, int stride) |
|
1439 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1440 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1441 |
Q_UNUSED(d); |
0 | 1442 |
if (location != -1) { |
1443 |
glVertexAttribPointer(location, 3, GL_FLOAT, GL_FALSE, |
|
1444 |
stride, values); |
|
1445 |
} |
|
1446 |
} |
|
1447 |
||
1448 |
/*! |
|
1449 |
Sets an array of 4D vertex \a values on the attribute at \a location |
|
1450 |
in this shader program. The \a stride indicates the number of bytes |
|
1451 |
between vertices. A default \a stride value of zero indicates that |
|
1452 |
the vertices are densely packed in \a values. |
|
1453 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1454 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1455 |
on the \a location. Otherwise the value specified with |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1456 |
setAttributeValue() for \a location will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1457 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1458 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1459 |
\sa disableAttributeArray() |
0 | 1460 |
*/ |
1461 |
void QGLShaderProgram::setAttributeArray |
|
1462 |
(int location, const QVector4D *values, int stride) |
|
1463 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1464 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1465 |
Q_UNUSED(d); |
0 | 1466 |
if (location != -1) { |
1467 |
glVertexAttribPointer(location, 4, GL_FLOAT, GL_FALSE, |
|
1468 |
stride, values); |
|
1469 |
} |
|
1470 |
} |
|
1471 |
||
1472 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1473 |
Sets an array of vertex \a values on the attribute at \a location |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1474 |
in this shader program. The \a stride indicates the number of bytes |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1475 |
between vertices. A default \a stride value of zero indicates that |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1476 |
the vertices are densely packed in \a values. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1477 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1478 |
The \a type indicates the type of elements in the \a values array, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1479 |
usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a tupleSize |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1480 |
indicates the number of components per vertex: 1, 2, 3, or 4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1481 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1482 |
The array will become active when enableAttributeArray() is called |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1483 |
on the \a location. Otherwise the value specified with |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1484 |
setAttributeValue() for \a location will be used. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1485 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1486 |
The setAttributeBuffer() function can be used to set the attribute |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1487 |
array to an offset within a vertex buffer. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1488 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1489 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1490 |
\sa disableAttributeArray(), setAttributeBuffer() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1491 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1492 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1493 |
void QGLShaderProgram::setAttributeArray |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1494 |
(int location, GLenum type, const void *values, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1495 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1496 |
Q_D(QGLShaderProgram); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1497 |
Q_UNUSED(d); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1498 |
if (location != -1) { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1499 |
glVertexAttribPointer(location, tupleSize, type, GL_TRUE, |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1500 |
stride, values); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1501 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1502 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1503 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1504 |
/*! |
0 | 1505 |
\overload |
1506 |
||
1507 |
Sets an array of vertex \a values on the attribute called \a name |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1508 |
in this shader program. The \a tupleSize indicates the number of |
0 | 1509 |
components per vertex (1, 2, 3, or 4), and the \a stride indicates |
1510 |
the number of bytes between vertices. A default \a stride value |
|
1511 |
of zero indicates that the vertices are densely packed in \a values. |
|
1512 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1513 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1514 |
on \a name. Otherwise the value specified with setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1515 |
for \a name will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1516 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1517 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1518 |
\sa disableAttributeArray() |
0 | 1519 |
*/ |
1520 |
void QGLShaderProgram::setAttributeArray |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1521 |
(const char *name, const GLfloat *values, int tupleSize, int stride) |
0 | 1522 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1523 |
setAttributeArray(attributeLocation(name), values, tupleSize, stride); |
0 | 1524 |
} |
1525 |
||
1526 |
/*! |
|
1527 |
\overload |
|
1528 |
||
1529 |
Sets an array of 2D vertex \a values on the attribute called \a name |
|
1530 |
in this shader program. The \a stride indicates the number of bytes |
|
1531 |
between vertices. A default \a stride value of zero indicates that |
|
1532 |
the vertices are densely packed in \a values. |
|
1533 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1534 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1535 |
on \a name. Otherwise the value specified with setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1536 |
for \a name will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1537 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1538 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1539 |
\sa disableAttributeArray() |
0 | 1540 |
*/ |
1541 |
void QGLShaderProgram::setAttributeArray |
|
1542 |
(const char *name, const QVector2D *values, int stride) |
|
1543 |
{ |
|
1544 |
setAttributeArray(attributeLocation(name), values, stride); |
|
1545 |
} |
|
1546 |
||
1547 |
/*! |
|
1548 |
\overload |
|
1549 |
||
1550 |
Sets an array of 3D vertex \a values on the attribute called \a name |
|
1551 |
in this shader program. The \a stride indicates the number of bytes |
|
1552 |
between vertices. A default \a stride value of zero indicates that |
|
1553 |
the vertices are densely packed in \a values. |
|
1554 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1555 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1556 |
on \a name. Otherwise the value specified with setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1557 |
for \a name will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1558 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1559 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1560 |
\sa disableAttributeArray() |
0 | 1561 |
*/ |
1562 |
void QGLShaderProgram::setAttributeArray |
|
1563 |
(const char *name, const QVector3D *values, int stride) |
|
1564 |
{ |
|
1565 |
setAttributeArray(attributeLocation(name), values, stride); |
|
1566 |
} |
|
1567 |
||
1568 |
/*! |
|
1569 |
\overload |
|
1570 |
||
1571 |
Sets an array of 4D vertex \a values on the attribute called \a name |
|
1572 |
in this shader program. The \a stride indicates the number of bytes |
|
1573 |
between vertices. A default \a stride value of zero indicates that |
|
1574 |
the vertices are densely packed in \a values. |
|
1575 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1576 |
The array will become active when enableAttributeArray() is called |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1577 |
on \a name. Otherwise the value specified with setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1578 |
for \a name will be used. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1579 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1580 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1581 |
\sa disableAttributeArray() |
0 | 1582 |
*/ |
1583 |
void QGLShaderProgram::setAttributeArray |
|
1584 |
(const char *name, const QVector4D *values, int stride) |
|
1585 |
{ |
|
1586 |
setAttributeArray(attributeLocation(name), values, stride); |
|
1587 |
} |
|
1588 |
||
1589 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1590 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1591 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1592 |
Sets an array of vertex \a values on the attribute called \a name |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1593 |
in this shader program. The \a stride indicates the number of bytes |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1594 |
between vertices. A default \a stride value of zero indicates that |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1595 |
the vertices are densely packed in \a values. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1596 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1597 |
The \a type indicates the type of elements in the \a values array, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1598 |
usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a tupleSize |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1599 |
indicates the number of components per vertex: 1, 2, 3, or 4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1600 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1601 |
The array will become active when enableAttributeArray() is called |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1602 |
on the \a name. Otherwise the value specified with |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1603 |
setAttributeValue() for \a name will be used. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1604 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1605 |
The setAttributeBuffer() function can be used to set the attribute |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1606 |
array to an offset within a vertex buffer. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1607 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1608 |
\sa setAttributeValue(), setUniformValue(), enableAttributeArray() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1609 |
\sa disableAttributeArray(), setAttributeBuffer() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1610 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1611 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1612 |
void QGLShaderProgram::setAttributeArray |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1613 |
(const char *name, GLenum type, const void *values, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1614 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1615 |
setAttributeArray(attributeLocation(name), type, values, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1616 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1617 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1618 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1619 |
Sets an array of vertex values on the attribute at \a location in |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1620 |
this shader program, starting at a specific \a offset in the |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1621 |
currently bound vertex buffer. The \a stride indicates the number |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1622 |
of bytes between vertices. A default \a stride value of zero |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1623 |
indicates that the vertices are densely packed in the value array. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1624 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1625 |
The \a type indicates the type of elements in the vertex value |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1626 |
array, usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1627 |
tupleSize indicates the number of components per vertex: 1, 2, 3, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1628 |
or 4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1629 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1630 |
The array will become active when enableAttributeArray() is called |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1631 |
on the \a location. Otherwise the value specified with |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1632 |
setAttributeValue() for \a location will be used. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1633 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1634 |
\sa setAttributeArray() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1635 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1636 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1637 |
void QGLShaderProgram::setAttributeBuffer |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1638 |
(int location, GLenum type, int offset, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1639 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1640 |
Q_D(QGLShaderProgram); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1641 |
Q_UNUSED(d); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1642 |
if (location != -1) { |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
1643 |
glVertexAttribPointer(location, tupleSize, type, GL_TRUE, stride, |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1644 |
reinterpret_cast<const void *>(offset)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1645 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1646 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1647 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1648 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1649 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1650 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1651 |
Sets an array of vertex values on the attribute called \a name |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1652 |
in this shader program, starting at a specific \a offset in the |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1653 |
currently bound vertex buffer. The \a stride indicates the number |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1654 |
of bytes between vertices. A default \a stride value of zero |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1655 |
indicates that the vertices are densely packed in the value array. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1656 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1657 |
The \a type indicates the type of elements in the vertex value |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1658 |
array, usually \c{GL_FLOAT}, \c{GL_UNSIGNED_BYTE}, etc. The \a |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1659 |
tupleSize indicates the number of components per vertex: 1, 2, 3, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1660 |
or 4. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1661 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1662 |
The array will become active when enableAttributeArray() is called |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1663 |
on the \a name. Otherwise the value specified with |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1664 |
setAttributeValue() for \a name will be used. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1665 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1666 |
\sa setAttributeArray() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1667 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1668 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1669 |
void QGLShaderProgram::setAttributeBuffer |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1670 |
(const char *name, GLenum type, int offset, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1671 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1672 |
setAttributeBuffer(attributeLocation(name), type, offset, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1673 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1674 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
1675 |
/*! |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1676 |
Enables the vertex array at \a location in this shader program |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1677 |
so that the value set by setAttributeArray() on \a location |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1678 |
will be used by the shader program. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1679 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1680 |
\sa disableAttributeArray(), setAttributeArray(), setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1681 |
\sa setUniformValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1682 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1683 |
void QGLShaderProgram::enableAttributeArray(int location) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1684 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1685 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1686 |
Q_UNUSED(d); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1687 |
if (location != -1) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1688 |
glEnableVertexAttribArray(location); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1689 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1690 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1691 |
/*! |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1692 |
\overload |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1693 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1694 |
Enables the vertex array called \a name in this shader program |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1695 |
so that the value set by setAttributeArray() on \a name |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1696 |
will be used by the shader program. |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1697 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1698 |
\sa disableAttributeArray(), setAttributeArray(), setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1699 |
\sa setUniformValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1700 |
*/ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1701 |
void QGLShaderProgram::enableAttributeArray(const char *name) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1702 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1703 |
enableAttributeArray(attributeLocation(name)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1704 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1705 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1706 |
/*! |
0 | 1707 |
Disables the vertex array at \a location in this shader program |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1708 |
that was enabled by a previous call to enableAttributeArray(). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1709 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1710 |
\sa enableAttributeArray(), setAttributeArray(), setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1711 |
\sa setUniformValue() |
0 | 1712 |
*/ |
1713 |
void QGLShaderProgram::disableAttributeArray(int location) |
|
1714 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1715 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1716 |
Q_UNUSED(d); |
0 | 1717 |
if (location != -1) |
1718 |
glDisableVertexAttribArray(location); |
|
1719 |
} |
|
1720 |
||
1721 |
/*! |
|
1722 |
\overload |
|
1723 |
||
1724 |
Disables the vertex array called \a name in this shader program |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1725 |
that was enabled by a previous call to enableAttributeArray(). |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1726 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1727 |
\sa enableAttributeArray(), setAttributeArray(), setAttributeValue() |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1728 |
\sa setUniformValue() |
0 | 1729 |
*/ |
1730 |
void QGLShaderProgram::disableAttributeArray(const char *name) |
|
1731 |
{ |
|
1732 |
disableAttributeArray(attributeLocation(name)); |
|
1733 |
} |
|
1734 |
||
1735 |
/*! |
|
1736 |
Returns the location of the uniform variable \a name within this shader |
|
1737 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1738 |
uniform variable for this shader program. |
|
1739 |
||
1740 |
\sa attributeLocation() |
|
1741 |
*/ |
|
1742 |
int QGLShaderProgram::uniformLocation(const char *name) const |
|
1743 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1744 |
Q_D(const QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1745 |
Q_UNUSED(d); |
0 | 1746 |
if (d->linked) { |
1747 |
return glGetUniformLocation(d->programGuard.id(), name); |
|
1748 |
} else { |
|
1749 |
qWarning() << "QGLShaderProgram::uniformLocation(" << name |
|
1750 |
<< "): shader program is not linked"; |
|
1751 |
return -1; |
|
1752 |
} |
|
1753 |
} |
|
1754 |
||
1755 |
/*! |
|
1756 |
\overload |
|
1757 |
||
1758 |
Returns the location of the uniform variable \a name within this shader |
|
1759 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1760 |
uniform variable for this shader program. |
|
1761 |
||
1762 |
\sa attributeLocation() |
|
1763 |
*/ |
|
1764 |
int QGLShaderProgram::uniformLocation(const QByteArray& name) const |
|
1765 |
{ |
|
1766 |
return uniformLocation(name.constData()); |
|
1767 |
} |
|
1768 |
||
1769 |
/*! |
|
1770 |
\overload |
|
1771 |
||
1772 |
Returns the location of the uniform variable \a name within this shader |
|
1773 |
program's parameter list. Returns -1 if \a name is not a valid |
|
1774 |
uniform variable for this shader program. |
|
1775 |
||
1776 |
\sa attributeLocation() |
|
1777 |
*/ |
|
1778 |
int QGLShaderProgram::uniformLocation(const QString& name) const |
|
1779 |
{ |
|
1780 |
return uniformLocation(name.toLatin1().constData()); |
|
1781 |
} |
|
1782 |
||
1783 |
/*! |
|
1784 |
Sets the uniform variable at \a location in the current context to \a value. |
|
1785 |
||
1786 |
\sa setAttributeValue() |
|
1787 |
*/ |
|
1788 |
void QGLShaderProgram::setUniformValue(int location, GLfloat value) |
|
1789 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1790 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1791 |
Q_UNUSED(d); |
0 | 1792 |
if (location != -1) |
1793 |
glUniform1fv(location, 1, &value); |
|
1794 |
} |
|
1795 |
||
1796 |
/*! |
|
1797 |
\overload |
|
1798 |
||
1799 |
Sets the uniform variable called \a name in the current context |
|
1800 |
to \a value. |
|
1801 |
||
1802 |
\sa setAttributeValue() |
|
1803 |
*/ |
|
1804 |
void QGLShaderProgram::setUniformValue(const char *name, GLfloat value) |
|
1805 |
{ |
|
1806 |
setUniformValue(uniformLocation(name), value); |
|
1807 |
} |
|
1808 |
||
1809 |
/*! |
|
1810 |
Sets the uniform variable at \a location in the current context to \a value. |
|
1811 |
||
1812 |
\sa setAttributeValue() |
|
1813 |
*/ |
|
1814 |
void QGLShaderProgram::setUniformValue(int location, GLint value) |
|
1815 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1816 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1817 |
Q_UNUSED(d); |
0 | 1818 |
if (location != -1) |
1819 |
glUniform1i(location, value); |
|
1820 |
} |
|
1821 |
||
1822 |
/*! |
|
1823 |
\overload |
|
1824 |
||
1825 |
Sets the uniform variable called \a name in the current context |
|
1826 |
to \a value. |
|
1827 |
||
1828 |
\sa setAttributeValue() |
|
1829 |
*/ |
|
1830 |
void QGLShaderProgram::setUniformValue(const char *name, GLint value) |
|
1831 |
{ |
|
1832 |
setUniformValue(uniformLocation(name), value); |
|
1833 |
} |
|
1834 |
||
1835 |
/*! |
|
1836 |
Sets the uniform variable at \a location in the current context to \a value. |
|
1837 |
This function should be used when setting sampler values. |
|
1838 |
||
1839 |
\sa setAttributeValue() |
|
1840 |
*/ |
|
1841 |
void QGLShaderProgram::setUniformValue(int location, GLuint value) |
|
1842 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1843 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1844 |
Q_UNUSED(d); |
0 | 1845 |
if (location != -1) |
1846 |
glUniform1i(location, value); |
|
1847 |
} |
|
1848 |
||
1849 |
/*! |
|
1850 |
\overload |
|
1851 |
||
1852 |
Sets the uniform variable called \a name in the current context |
|
1853 |
to \a value. This function should be used when setting sampler values. |
|
1854 |
||
1855 |
\sa setAttributeValue() |
|
1856 |
*/ |
|
1857 |
void QGLShaderProgram::setUniformValue(const char *name, GLuint value) |
|
1858 |
{ |
|
1859 |
setUniformValue(uniformLocation(name), value); |
|
1860 |
} |
|
1861 |
||
1862 |
/*! |
|
1863 |
Sets the uniform variable at \a location in the current context to |
|
1864 |
the 2D vector (\a x, \a y). |
|
1865 |
||
1866 |
\sa setAttributeValue() |
|
1867 |
*/ |
|
1868 |
void QGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y) |
|
1869 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1870 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1871 |
Q_UNUSED(d); |
0 | 1872 |
if (location != -1) { |
1873 |
GLfloat values[2] = {x, y}; |
|
1874 |
glUniform2fv(location, 1, values); |
|
1875 |
} |
|
1876 |
} |
|
1877 |
||
1878 |
/*! |
|
1879 |
\overload |
|
1880 |
||
1881 |
Sets the uniform variable called \a name in the current context to |
|
1882 |
the 2D vector (\a x, \a y). |
|
1883 |
||
1884 |
\sa setAttributeValue() |
|
1885 |
*/ |
|
1886 |
void QGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y) |
|
1887 |
{ |
|
1888 |
setUniformValue(uniformLocation(name), x, y); |
|
1889 |
} |
|
1890 |
||
1891 |
/*! |
|
1892 |
Sets the uniform variable at \a location in the current context to |
|
1893 |
the 3D vector (\a x, \a y, \a z). |
|
1894 |
||
1895 |
\sa setAttributeValue() |
|
1896 |
*/ |
|
1897 |
void QGLShaderProgram::setUniformValue |
|
1898 |
(int location, GLfloat x, GLfloat y, GLfloat z) |
|
1899 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1900 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1901 |
Q_UNUSED(d); |
0 | 1902 |
if (location != -1) { |
1903 |
GLfloat values[3] = {x, y, z}; |
|
1904 |
glUniform3fv(location, 1, values); |
|
1905 |
} |
|
1906 |
} |
|
1907 |
||
1908 |
/*! |
|
1909 |
\overload |
|
1910 |
||
1911 |
Sets the uniform variable called \a name in the current context to |
|
1912 |
the 3D vector (\a x, \a y, \a z). |
|
1913 |
||
1914 |
\sa setAttributeValue() |
|
1915 |
*/ |
|
1916 |
void QGLShaderProgram::setUniformValue |
|
1917 |
(const char *name, GLfloat x, GLfloat y, GLfloat z) |
|
1918 |
{ |
|
1919 |
setUniformValue(uniformLocation(name), x, y, z); |
|
1920 |
} |
|
1921 |
||
1922 |
/*! |
|
1923 |
Sets the uniform variable at \a location in the current context to |
|
1924 |
the 4D vector (\a x, \a y, \a z, \a w). |
|
1925 |
||
1926 |
\sa setAttributeValue() |
|
1927 |
*/ |
|
1928 |
void QGLShaderProgram::setUniformValue |
|
1929 |
(int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
|
1930 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1931 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1932 |
Q_UNUSED(d); |
0 | 1933 |
if (location != -1) { |
1934 |
GLfloat values[4] = {x, y, z, w}; |
|
1935 |
glUniform4fv(location, 1, values); |
|
1936 |
} |
|
1937 |
} |
|
1938 |
||
1939 |
/*! |
|
1940 |
\overload |
|
1941 |
||
1942 |
Sets the uniform variable called \a name in the current context to |
|
1943 |
the 4D vector (\a x, \a y, \a z, \a w). |
|
1944 |
||
1945 |
\sa setAttributeValue() |
|
1946 |
*/ |
|
1947 |
void QGLShaderProgram::setUniformValue |
|
1948 |
(const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) |
|
1949 |
{ |
|
1950 |
setUniformValue(uniformLocation(name), x, y, z, w); |
|
1951 |
} |
|
1952 |
||
1953 |
/*! |
|
1954 |
Sets the uniform variable at \a location in the current context to \a value. |
|
1955 |
||
1956 |
\sa setAttributeValue() |
|
1957 |
*/ |
|
1958 |
void QGLShaderProgram::setUniformValue(int location, const QVector2D& value) |
|
1959 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1960 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1961 |
Q_UNUSED(d); |
0 | 1962 |
if (location != -1) |
1963 |
glUniform2fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); |
|
1964 |
} |
|
1965 |
||
1966 |
/*! |
|
1967 |
\overload |
|
1968 |
||
1969 |
Sets the uniform variable called \a name in the current context |
|
1970 |
to \a value. |
|
1971 |
||
1972 |
\sa setAttributeValue() |
|
1973 |
*/ |
|
1974 |
void QGLShaderProgram::setUniformValue(const char *name, const QVector2D& value) |
|
1975 |
{ |
|
1976 |
setUniformValue(uniformLocation(name), value); |
|
1977 |
} |
|
1978 |
||
1979 |
/*! |
|
1980 |
Sets the uniform variable at \a location in the current context to \a value. |
|
1981 |
||
1982 |
\sa setAttributeValue() |
|
1983 |
*/ |
|
1984 |
void QGLShaderProgram::setUniformValue(int location, const QVector3D& value) |
|
1985 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1986 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1987 |
Q_UNUSED(d); |
0 | 1988 |
if (location != -1) |
1989 |
glUniform3fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); |
|
1990 |
} |
|
1991 |
||
1992 |
/*! |
|
1993 |
\overload |
|
1994 |
||
1995 |
Sets the uniform variable called \a name in the current context |
|
1996 |
to \a value. |
|
1997 |
||
1998 |
\sa setAttributeValue() |
|
1999 |
*/ |
|
2000 |
void QGLShaderProgram::setUniformValue(const char *name, const QVector3D& value) |
|
2001 |
{ |
|
2002 |
setUniformValue(uniformLocation(name), value); |
|
2003 |
} |
|
2004 |
||
2005 |
/*! |
|
2006 |
Sets the uniform variable at \a location in the current context to \a value. |
|
2007 |
||
2008 |
\sa setAttributeValue() |
|
2009 |
*/ |
|
2010 |
void QGLShaderProgram::setUniformValue(int location, const QVector4D& value) |
|
2011 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2012 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2013 |
Q_UNUSED(d); |
0 | 2014 |
if (location != -1) |
2015 |
glUniform4fv(location, 1, reinterpret_cast<const GLfloat *>(&value)); |
|
2016 |
} |
|
2017 |
||
2018 |
/*! |
|
2019 |
\overload |
|
2020 |
||
2021 |
Sets the uniform variable called \a name in the current context |
|
2022 |
to \a value. |
|
2023 |
||
2024 |
\sa setAttributeValue() |
|
2025 |
*/ |
|
2026 |
void QGLShaderProgram::setUniformValue(const char *name, const QVector4D& value) |
|
2027 |
{ |
|
2028 |
setUniformValue(uniformLocation(name), value); |
|
2029 |
} |
|
2030 |
||
2031 |
/*! |
|
2032 |
Sets the uniform variable at \a location in the current context to |
|
2033 |
the red, green, blue, and alpha components of \a color. |
|
2034 |
||
2035 |
\sa setAttributeValue() |
|
2036 |
*/ |
|
2037 |
void QGLShaderProgram::setUniformValue(int location, const QColor& color) |
|
2038 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2039 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2040 |
Q_UNUSED(d); |
0 | 2041 |
if (location != -1) { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2042 |
GLfloat values[4] = {GLfloat(color.redF()), GLfloat(color.greenF()), |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2043 |
GLfloat(color.blueF()), GLfloat(color.alphaF())}; |
0 | 2044 |
glUniform4fv(location, 1, values); |
2045 |
} |
|
2046 |
} |
|
2047 |
||
2048 |
/*! |
|
2049 |
\overload |
|
2050 |
||
2051 |
Sets the uniform variable called \a name in the current context to |
|
2052 |
the red, green, blue, and alpha components of \a color. |
|
2053 |
||
2054 |
\sa setAttributeValue() |
|
2055 |
*/ |
|
2056 |
void QGLShaderProgram::setUniformValue(const char *name, const QColor& color) |
|
2057 |
{ |
|
2058 |
setUniformValue(uniformLocation(name), color); |
|
2059 |
} |
|
2060 |
||
2061 |
/*! |
|
2062 |
Sets the uniform variable at \a location in the current context to |
|
2063 |
the x and y coordinates of \a point. |
|
2064 |
||
2065 |
\sa setAttributeValue() |
|
2066 |
*/ |
|
2067 |
void QGLShaderProgram::setUniformValue(int location, const QPoint& point) |
|
2068 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2069 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2070 |
Q_UNUSED(d); |
0 | 2071 |
if (location != -1) { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2072 |
GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())}; |
0 | 2073 |
glUniform2fv(location, 1, values); |
2074 |
} |
|
2075 |
} |
|
2076 |
||
2077 |
/*! |
|
2078 |
\overload |
|
2079 |
||
2080 |
Sets the uniform variable associated with \a name in the current |
|
2081 |
context to the x and y coordinates of \a point. |
|
2082 |
||
2083 |
\sa setAttributeValue() |
|
2084 |
*/ |
|
2085 |
void QGLShaderProgram::setUniformValue(const char *name, const QPoint& point) |
|
2086 |
{ |
|
2087 |
setUniformValue(uniformLocation(name), point); |
|
2088 |
} |
|
2089 |
||
2090 |
/*! |
|
2091 |
Sets the uniform variable at \a location in the current context to |
|
2092 |
the x and y coordinates of \a point. |
|
2093 |
||
2094 |
\sa setAttributeValue() |
|
2095 |
*/ |
|
2096 |
void QGLShaderProgram::setUniformValue(int location, const QPointF& point) |
|
2097 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2098 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2099 |
Q_UNUSED(d); |
0 | 2100 |
if (location != -1) { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2101 |
GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())}; |
0 | 2102 |
glUniform2fv(location, 1, values); |
2103 |
} |
|
2104 |
} |
|
2105 |
||
2106 |
/*! |
|
2107 |
\overload |
|
2108 |
||
2109 |
Sets the uniform variable associated with \a name in the current |
|
2110 |
context to the x and y coordinates of \a point. |
|
2111 |
||
2112 |
\sa setAttributeValue() |
|
2113 |
*/ |
|
2114 |
void QGLShaderProgram::setUniformValue(const char *name, const QPointF& point) |
|
2115 |
{ |
|
2116 |
setUniformValue(uniformLocation(name), point); |
|
2117 |
} |
|
2118 |
||
2119 |
/*! |
|
2120 |
Sets the uniform variable at \a location in the current context to |
|
2121 |
the width and height of the given \a size. |
|
2122 |
||
2123 |
\sa setAttributeValue() |
|
2124 |
*/ |
|
2125 |
void QGLShaderProgram::setUniformValue(int location, const QSize& size) |
|
2126 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2127 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2128 |
Q_UNUSED(d); |
0 | 2129 |
if (location != -1) { |
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
2130 |
GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())}; |
0 | 2131 |
glUniform2fv(location, 1, values); |
2132 |
} |
|
2133 |
} |
|
2134 |
||
2135 |
/*! |
|
2136 |
\overload |
|
2137 |
||
2138 |
Sets the uniform variable associated with \a name in the current |
|
2139 |
context to the width and height of the given \a size. |
|
2140 |
||
2141 |
\sa setAttributeValue() |
|
2142 |
*/ |
|
2143 |
void QGLShaderProgram::setUniformValue(const char *name, const QSize& size) |
|
2144 |
{ |
|
2145 |
setUniformValue(uniformLocation(name), size); |
|
2146 |
} |
|
2147 |
||
2148 |
/*! |
|
2149 |
Sets the uniform variable at \a location in the current context to |
|
2150 |
the width and height of the given \a size. |
|
2151 |
||
2152 |
\sa setAttributeValue() |
|
2153 |
*/ |
|
2154 |
void QGLShaderProgram::setUniformValue(int location, const QSizeF& size) |
|
2155 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2156 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2157 |
Q_UNUSED(d); |
0 | 2158 |
if (location != -1) { |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2159 |
GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())}; |
0 | 2160 |
glUniform2fv(location, 1, values); |
2161 |
} |
|
2162 |
} |
|
2163 |
||
2164 |
/*! |
|
2165 |
\overload |
|
2166 |
||
2167 |
Sets the uniform variable associated with \a name in the current |
|
2168 |
context to the width and height of the given \a size. |
|
2169 |
||
2170 |
\sa setAttributeValue() |
|
2171 |
*/ |
|
2172 |
void QGLShaderProgram::setUniformValue(const char *name, const QSizeF& size) |
|
2173 |
{ |
|
2174 |
setUniformValue(uniformLocation(name), size); |
|
2175 |
} |
|
2176 |
||
2177 |
// We have to repack matrices from qreal to GLfloat. |
|
2178 |
#define setUniformMatrix(func,location,value,cols,rows) \ |
|
2179 |
if (location == -1) \ |
|
2180 |
return; \ |
|
2181 |
if (sizeof(qreal) == sizeof(GLfloat)) { \ |
|
2182 |
func(location, 1, GL_FALSE, \ |
|
2183 |
reinterpret_cast<const GLfloat *>(value.constData())); \ |
|
2184 |
} else { \ |
|
2185 |
GLfloat mat[cols * rows]; \ |
|
2186 |
const qreal *data = value.constData(); \ |
|
2187 |
for (int i = 0; i < cols * rows; ++i) \ |
|
2188 |
mat[i] = data[i]; \ |
|
2189 |
func(location, 1, GL_FALSE, mat); \ |
|
2190 |
} |
|
2191 |
#if !defined(QT_OPENGL_ES_2) |
|
2192 |
#define setUniformGenericMatrix(func,colfunc,location,value,cols,rows) \ |
|
2193 |
if (location == -1) \ |
|
2194 |
return; \ |
|
2195 |
if (sizeof(qreal) == sizeof(GLfloat)) { \ |
|
2196 |
const GLfloat *data = reinterpret_cast<const GLfloat *> \ |
|
2197 |
(value.constData()); \ |
|
2198 |
if (func) \ |
|
2199 |
func(location, 1, GL_FALSE, data); \ |
|
2200 |
else \ |
|
2201 |
colfunc(location, cols, data); \ |
|
2202 |
} else { \ |
|
2203 |
GLfloat mat[cols * rows]; \ |
|
2204 |
const qreal *data = value.constData(); \ |
|
2205 |
for (int i = 0; i < cols * rows; ++i) \ |
|
2206 |
mat[i] = data[i]; \ |
|
2207 |
if (func) \ |
|
2208 |
func(location, 1, GL_FALSE, mat); \ |
|
2209 |
else \ |
|
2210 |
colfunc(location, cols, mat); \ |
|
2211 |
} |
|
2212 |
#else |
|
2213 |
#define setUniformGenericMatrix(func,colfunc,location,value,cols,rows) \ |
|
2214 |
if (location == -1) \ |
|
2215 |
return; \ |
|
2216 |
if (sizeof(qreal) == sizeof(GLfloat)) { \ |
|
2217 |
const GLfloat *data = reinterpret_cast<const GLfloat *> \ |
|
2218 |
(value.constData()); \ |
|
2219 |
colfunc(location, cols, data); \ |
|
2220 |
} else { \ |
|
2221 |
GLfloat mat[cols * rows]; \ |
|
2222 |
const qreal *data = value.constData(); \ |
|
2223 |
for (int i = 0; i < cols * rows; ++i) \ |
|
2224 |
mat[i] = data[i]; \ |
|
2225 |
colfunc(location, cols, mat); \ |
|
2226 |
} |
|
2227 |
#endif |
|
2228 |
||
2229 |
/*! |
|
2230 |
Sets the uniform variable at \a location in the current context |
|
2231 |
to a 2x2 matrix \a value. |
|
2232 |
||
2233 |
\sa setAttributeValue() |
|
2234 |
*/ |
|
2235 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value) |
|
2236 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2237 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2238 |
Q_UNUSED(d); |
0 | 2239 |
setUniformMatrix(glUniformMatrix2fv, location, value, 2, 2); |
2240 |
} |
|
2241 |
||
2242 |
/*! |
|
2243 |
\overload |
|
2244 |
||
2245 |
Sets the uniform variable called \a name in the current context |
|
2246 |
to a 2x2 matrix \a value. |
|
2247 |
||
2248 |
\sa setAttributeValue() |
|
2249 |
*/ |
|
2250 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value) |
|
2251 |
{ |
|
2252 |
setUniformValue(uniformLocation(name), value); |
|
2253 |
} |
|
2254 |
||
2255 |
/*! |
|
2256 |
Sets the uniform variable at \a location in the current context |
|
2257 |
to a 2x3 matrix \a value. |
|
2258 |
||
2259 |
\sa setAttributeValue() |
|
2260 |
*/ |
|
2261 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value) |
|
2262 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2263 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2264 |
Q_UNUSED(d); |
0 | 2265 |
setUniformGenericMatrix |
2266 |
(glUniformMatrix2x3fv, glUniform3fv, location, value, 2, 3); |
|
2267 |
} |
|
2268 |
||
2269 |
/*! |
|
2270 |
\overload |
|
2271 |
||
2272 |
Sets the uniform variable called \a name in the current context |
|
2273 |
to a 2x3 matrix \a value. |
|
2274 |
||
2275 |
\sa setAttributeValue() |
|
2276 |
*/ |
|
2277 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value) |
|
2278 |
{ |
|
2279 |
setUniformValue(uniformLocation(name), value); |
|
2280 |
} |
|
2281 |
||
2282 |
/*! |
|
2283 |
Sets the uniform variable at \a location in the current context |
|
2284 |
to a 2x4 matrix \a value. |
|
2285 |
||
2286 |
\sa setAttributeValue() |
|
2287 |
*/ |
|
2288 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value) |
|
2289 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2290 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2291 |
Q_UNUSED(d); |
0 | 2292 |
setUniformGenericMatrix |
2293 |
(glUniformMatrix2x4fv, glUniform4fv, location, value, 2, 4); |
|
2294 |
} |
|
2295 |
||
2296 |
/*! |
|
2297 |
\overload |
|
2298 |
||
2299 |
Sets the uniform variable called \a name in the current context |
|
2300 |
to a 2x4 matrix \a value. |
|
2301 |
||
2302 |
\sa setAttributeValue() |
|
2303 |
*/ |
|
2304 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value) |
|
2305 |
{ |
|
2306 |
setUniformValue(uniformLocation(name), value); |
|
2307 |
} |
|
2308 |
||
2309 |
/*! |
|
2310 |
Sets the uniform variable at \a location in the current context |
|
2311 |
to a 3x2 matrix \a value. |
|
2312 |
||
2313 |
\sa setAttributeValue() |
|
2314 |
*/ |
|
2315 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value) |
|
2316 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2317 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2318 |
Q_UNUSED(d); |
0 | 2319 |
setUniformGenericMatrix |
2320 |
(glUniformMatrix3x2fv, glUniform2fv, location, value, 3, 2); |
|
2321 |
} |
|
2322 |
||
2323 |
/*! |
|
2324 |
\overload |
|
2325 |
||
2326 |
Sets the uniform variable called \a name in the current context |
|
2327 |
to a 3x2 matrix \a value. |
|
2328 |
||
2329 |
\sa setAttributeValue() |
|
2330 |
*/ |
|
2331 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value) |
|
2332 |
{ |
|
2333 |
setUniformValue(uniformLocation(name), value); |
|
2334 |
} |
|
2335 |
||
2336 |
/*! |
|
2337 |
Sets the uniform variable at \a location in the current context |
|
2338 |
to a 3x3 matrix \a value. |
|
2339 |
||
2340 |
\sa setAttributeValue() |
|
2341 |
*/ |
|
2342 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value) |
|
2343 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2344 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2345 |
Q_UNUSED(d); |
0 | 2346 |
setUniformMatrix(glUniformMatrix3fv, location, value, 3, 3); |
2347 |
} |
|
2348 |
||
2349 |
/*! |
|
2350 |
\overload |
|
2351 |
||
2352 |
Sets the uniform variable called \a name in the current context |
|
2353 |
to a 3x3 matrix \a value. |
|
2354 |
||
2355 |
\sa setAttributeValue() |
|
2356 |
*/ |
|
2357 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value) |
|
2358 |
{ |
|
2359 |
setUniformValue(uniformLocation(name), value); |
|
2360 |
} |
|
2361 |
||
2362 |
/*! |
|
2363 |
Sets the uniform variable at \a location in the current context |
|
2364 |
to a 3x4 matrix \a value. |
|
2365 |
||
2366 |
\sa setAttributeValue() |
|
2367 |
*/ |
|
2368 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value) |
|
2369 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2370 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2371 |
Q_UNUSED(d); |
0 | 2372 |
setUniformGenericMatrix |
2373 |
(glUniformMatrix3x4fv, glUniform4fv, location, value, 3, 4); |
|
2374 |
} |
|
2375 |
||
2376 |
/*! |
|
2377 |
\overload |
|
2378 |
||
2379 |
Sets the uniform variable called \a name in the current context |
|
2380 |
to a 3x4 matrix \a value. |
|
2381 |
||
2382 |
\sa setAttributeValue() |
|
2383 |
*/ |
|
2384 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value) |
|
2385 |
{ |
|
2386 |
setUniformValue(uniformLocation(name), value); |
|
2387 |
} |
|
2388 |
||
2389 |
/*! |
|
2390 |
Sets the uniform variable at \a location in the current context |
|
2391 |
to a 4x2 matrix \a value. |
|
2392 |
||
2393 |
\sa setAttributeValue() |
|
2394 |
*/ |
|
2395 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value) |
|
2396 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2397 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2398 |
Q_UNUSED(d); |
0 | 2399 |
setUniformGenericMatrix |
2400 |
(glUniformMatrix4x2fv, glUniform2fv, location, value, 4, 2); |
|
2401 |
} |
|
2402 |
||
2403 |
/*! |
|
2404 |
\overload |
|
2405 |
||
2406 |
Sets the uniform variable called \a name in the current context |
|
2407 |
to a 4x2 matrix \a value. |
|
2408 |
||
2409 |
\sa setAttributeValue() |
|
2410 |
*/ |
|
2411 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value) |
|
2412 |
{ |
|
2413 |
setUniformValue(uniformLocation(name), value); |
|
2414 |
} |
|
2415 |
||
2416 |
/*! |
|
2417 |
Sets the uniform variable at \a location in the current context |
|
2418 |
to a 4x3 matrix \a value. |
|
2419 |
||
2420 |
\sa setAttributeValue() |
|
2421 |
*/ |
|
2422 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value) |
|
2423 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2424 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2425 |
Q_UNUSED(d); |
0 | 2426 |
setUniformGenericMatrix |
2427 |
(glUniformMatrix4x3fv, glUniform3fv, location, value, 4, 3); |
|
2428 |
} |
|
2429 |
||
2430 |
/*! |
|
2431 |
\overload |
|
2432 |
||
2433 |
Sets the uniform variable called \a name in the current context |
|
2434 |
to a 4x3 matrix \a value. |
|
2435 |
||
2436 |
\sa setAttributeValue() |
|
2437 |
*/ |
|
2438 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value) |
|
2439 |
{ |
|
2440 |
setUniformValue(uniformLocation(name), value); |
|
2441 |
} |
|
2442 |
||
2443 |
/*! |
|
2444 |
Sets the uniform variable at \a location in the current context |
|
2445 |
to a 4x4 matrix \a value. |
|
2446 |
||
2447 |
\sa setAttributeValue() |
|
2448 |
*/ |
|
2449 |
void QGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value) |
|
2450 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2451 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2452 |
Q_UNUSED(d); |
0 | 2453 |
setUniformMatrix(glUniformMatrix4fv, location, value, 4, 4); |
2454 |
} |
|
2455 |
||
2456 |
/*! |
|
2457 |
\overload |
|
2458 |
||
2459 |
Sets the uniform variable called \a name in the current context |
|
2460 |
to a 4x4 matrix \a value. |
|
2461 |
||
2462 |
\sa setAttributeValue() |
|
2463 |
*/ |
|
2464 |
void QGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value) |
|
2465 |
{ |
|
2466 |
setUniformValue(uniformLocation(name), value); |
|
2467 |
} |
|
2468 |
||
2469 |
/*! |
|
2470 |
\overload |
|
2471 |
||
2472 |
Sets the uniform variable at \a location in the current context |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2473 |
to a 2x2 matrix \a value. The matrix elements must be specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2474 |
in column-major order. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2475 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2476 |
\sa setAttributeValue() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2477 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2478 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2479 |
void QGLShaderProgram::setUniformValue(int location, const GLfloat value[2][2]) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2480 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2481 |
Q_D(QGLShaderProgram); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2482 |
Q_UNUSED(d); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2483 |
if (location != -1) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2484 |
glUniformMatrix2fv(location, 1, GL_FALSE, value[0]); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2485 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2486 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2487 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2488 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2489 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2490 |
Sets the uniform variable at \a location in the current context |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2491 |
to a 3x3 matrix \a value. The matrix elements must be specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2492 |
in column-major order. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2493 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2494 |
\sa setAttributeValue() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2495 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2496 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2497 |
void QGLShaderProgram::setUniformValue(int location, const GLfloat value[3][3]) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2498 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2499 |
Q_D(QGLShaderProgram); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2500 |
Q_UNUSED(d); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2501 |
if (location != -1) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2502 |
glUniformMatrix3fv(location, 1, GL_FALSE, value[0]); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2503 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2504 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2505 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2506 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2507 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2508 |
Sets the uniform variable at \a location in the current context |
0 | 2509 |
to a 4x4 matrix \a value. The matrix elements must be specified |
2510 |
in column-major order. |
|
2511 |
||
2512 |
\sa setAttributeValue() |
|
2513 |
*/ |
|
2514 |
void QGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4]) |
|
2515 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2516 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2517 |
Q_UNUSED(d); |
0 | 2518 |
if (location != -1) |
2519 |
glUniformMatrix4fv(location, 1, GL_FALSE, value[0]); |
|
2520 |
} |
|
2521 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2522 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2523 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2524 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2525 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2526 |
Sets the uniform variable called \a name in the current context |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2527 |
to a 2x2 matrix \a value. The matrix elements must be specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2528 |
in column-major order. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2529 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2530 |
\sa setAttributeValue() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2531 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2532 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2533 |
void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[2][2]) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2534 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2535 |
setUniformValue(uniformLocation(name), value); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2536 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2537 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2538 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2539 |
\overload |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2540 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2541 |
Sets the uniform variable called \a name in the current context |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2542 |
to a 3x3 matrix \a value. The matrix elements must be specified |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2543 |
in column-major order. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2544 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2545 |
\sa setAttributeValue() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2546 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2547 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2548 |
void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[3][3]) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2549 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2550 |
setUniformValue(uniformLocation(name), value); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2551 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2552 |
|
0 | 2553 |
/*! |
2554 |
\overload |
|
2555 |
||
2556 |
Sets the uniform variable called \a name in the current context |
|
2557 |
to a 4x4 matrix \a value. The matrix elements must be specified |
|
2558 |
in column-major order. |
|
2559 |
||
2560 |
\sa setAttributeValue() |
|
2561 |
*/ |
|
2562 |
void QGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][4]) |
|
2563 |
{ |
|
2564 |
setUniformValue(uniformLocation(name), value); |
|
2565 |
} |
|
2566 |
||
2567 |
/*! |
|
2568 |
Sets the uniform variable at \a location in the current context to a |
|
2569 |
3x3 transformation matrix \a value that is specified as a QTransform value. |
|
2570 |
||
2571 |
To set a QTransform value as a 4x4 matrix in a shader, use |
|
2572 |
\c{setUniformValue(location, QMatrix4x4(value))}. |
|
2573 |
*/ |
|
2574 |
void QGLShaderProgram::setUniformValue(int location, const QTransform& value) |
|
2575 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2576 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2577 |
Q_UNUSED(d); |
0 | 2578 |
if (location != -1) { |
2579 |
GLfloat mat[3][3] = { |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2580 |
{GLfloat(value.m11()), GLfloat(value.m12()), GLfloat(value.m13())}, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2581 |
{GLfloat(value.m21()), GLfloat(value.m22()), GLfloat(value.m23())}, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
2582 |
{GLfloat(value.m31()), GLfloat(value.m32()), GLfloat(value.m33())} |
0 | 2583 |
}; |
2584 |
glUniformMatrix3fv(location, 1, GL_FALSE, mat[0]); |
|
2585 |
} |
|
2586 |
} |
|
2587 |
||
2588 |
/*! |
|
2589 |
\overload |
|
2590 |
||
2591 |
Sets the uniform variable called \a name in the current context to a |
|
2592 |
3x3 transformation matrix \a value that is specified as a QTransform value. |
|
2593 |
||
2594 |
To set a QTransform value as a 4x4 matrix in a shader, use |
|
2595 |
\c{setUniformValue(name, QMatrix4x4(value))}. |
|
2596 |
*/ |
|
2597 |
void QGLShaderProgram::setUniformValue |
|
2598 |
(const char *name, const QTransform& value) |
|
2599 |
{ |
|
2600 |
setUniformValue(uniformLocation(name), value); |
|
2601 |
} |
|
2602 |
||
2603 |
/*! |
|
2604 |
Sets the uniform variable array at \a location in the current |
|
2605 |
context to the \a count elements of \a values. |
|
2606 |
||
2607 |
\sa setAttributeValue() |
|
2608 |
*/ |
|
2609 |
void QGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count) |
|
2610 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2611 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2612 |
Q_UNUSED(d); |
0 | 2613 |
if (location != -1) |
2614 |
glUniform1iv(location, count, values); |
|
2615 |
} |
|
2616 |
||
2617 |
/*! |
|
2618 |
\overload |
|
2619 |
||
2620 |
Sets the uniform variable array called \a name in the current |
|
2621 |
context to the \a count elements of \a values. |
|
2622 |
||
2623 |
\sa setAttributeValue() |
|
2624 |
*/ |
|
2625 |
void QGLShaderProgram::setUniformValueArray |
|
2626 |
(const char *name, const GLint *values, int count) |
|
2627 |
{ |
|
2628 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2629 |
} |
|
2630 |
||
2631 |
/*! |
|
2632 |
Sets the uniform variable array at \a location in the current |
|
2633 |
context to the \a count elements of \a values. This overload |
|
2634 |
should be used when setting an array of sampler values. |
|
2635 |
||
2636 |
\sa setAttributeValue() |
|
2637 |
*/ |
|
2638 |
void QGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count) |
|
2639 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2640 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2641 |
Q_UNUSED(d); |
0 | 2642 |
if (location != -1) |
2643 |
glUniform1iv(location, count, reinterpret_cast<const GLint *>(values)); |
|
2644 |
} |
|
2645 |
||
2646 |
/*! |
|
2647 |
\overload |
|
2648 |
||
2649 |
Sets the uniform variable array called \a name in the current |
|
2650 |
context to the \a count elements of \a values. This overload |
|
2651 |
should be used when setting an array of sampler values. |
|
2652 |
||
2653 |
\sa setAttributeValue() |
|
2654 |
*/ |
|
2655 |
void QGLShaderProgram::setUniformValueArray |
|
2656 |
(const char *name, const GLuint *values, int count) |
|
2657 |
{ |
|
2658 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2659 |
} |
|
2660 |
||
2661 |
/*! |
|
2662 |
Sets the uniform variable array at \a location in the current |
|
2663 |
context to the \a count elements of \a values. Each element |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2664 |
has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. |
0 | 2665 |
|
2666 |
\sa setAttributeValue() |
|
2667 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2668 |
void QGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize) |
0 | 2669 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2670 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2671 |
Q_UNUSED(d); |
0 | 2672 |
if (location != -1) { |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2673 |
if (tupleSize == 1) |
0 | 2674 |
glUniform1fv(location, count, values); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2675 |
else if (tupleSize == 2) |
0 | 2676 |
glUniform2fv(location, count, values); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2677 |
else if (tupleSize == 3) |
0 | 2678 |
glUniform3fv(location, count, values); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2679 |
else if (tupleSize == 4) |
0 | 2680 |
glUniform4fv(location, count, values); |
2681 |
else |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2682 |
qWarning() << "QGLShaderProgram::setUniformValue: size" << tupleSize << "not supported"; |
0 | 2683 |
} |
2684 |
} |
|
2685 |
||
2686 |
/*! |
|
2687 |
\overload |
|
2688 |
||
2689 |
Sets the uniform variable array called \a name in the current |
|
2690 |
context to the \a count elements of \a values. Each element |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2691 |
has \a tupleSize components. The \a tupleSize must be 1, 2, 3, or 4. |
0 | 2692 |
|
2693 |
\sa setAttributeValue() |
|
2694 |
*/ |
|
2695 |
void QGLShaderProgram::setUniformValueArray |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2696 |
(const char *name, const GLfloat *values, int count, int tupleSize) |
0 | 2697 |
{ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2698 |
setUniformValueArray(uniformLocation(name), values, count, tupleSize); |
0 | 2699 |
} |
2700 |
||
2701 |
/*! |
|
2702 |
Sets the uniform variable array at \a location in the current |
|
2703 |
context to the \a count 2D vector elements of \a values. |
|
2704 |
||
2705 |
\sa setAttributeValue() |
|
2706 |
*/ |
|
2707 |
void QGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count) |
|
2708 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2709 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2710 |
Q_UNUSED(d); |
0 | 2711 |
if (location != -1) |
2712 |
glUniform2fv(location, count, reinterpret_cast<const GLfloat *>(values)); |
|
2713 |
} |
|
2714 |
||
2715 |
/*! |
|
2716 |
\overload |
|
2717 |
||
2718 |
Sets the uniform variable array called \a name in the current |
|
2719 |
context to the \a count 2D vector elements of \a values. |
|
2720 |
||
2721 |
\sa setAttributeValue() |
|
2722 |
*/ |
|
2723 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *values, int count) |
|
2724 |
{ |
|
2725 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2726 |
} |
|
2727 |
||
2728 |
/*! |
|
2729 |
Sets the uniform variable array at \a location in the current |
|
2730 |
context to the \a count 3D vector elements of \a values. |
|
2731 |
||
2732 |
\sa setAttributeValue() |
|
2733 |
*/ |
|
2734 |
void QGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count) |
|
2735 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2736 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2737 |
Q_UNUSED(d); |
0 | 2738 |
if (location != -1) |
2739 |
glUniform3fv(location, count, reinterpret_cast<const GLfloat *>(values)); |
|
2740 |
} |
|
2741 |
||
2742 |
/*! |
|
2743 |
\overload |
|
2744 |
||
2745 |
Sets the uniform variable array called \a name in the current |
|
2746 |
context to the \a count 3D vector elements of \a values. |
|
2747 |
||
2748 |
\sa setAttributeValue() |
|
2749 |
*/ |
|
2750 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *values, int count) |
|
2751 |
{ |
|
2752 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2753 |
} |
|
2754 |
||
2755 |
/*! |
|
2756 |
Sets the uniform variable array at \a location in the current |
|
2757 |
context to the \a count 4D vector elements of \a values. |
|
2758 |
||
2759 |
\sa setAttributeValue() |
|
2760 |
*/ |
|
2761 |
void QGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count) |
|
2762 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2763 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2764 |
Q_UNUSED(d); |
0 | 2765 |
if (location != -1) |
2766 |
glUniform4fv(location, count, reinterpret_cast<const GLfloat *>(values)); |
|
2767 |
} |
|
2768 |
||
2769 |
/*! |
|
2770 |
\overload |
|
2771 |
||
2772 |
Sets the uniform variable array called \a name in the current |
|
2773 |
context to the \a count 4D vector elements of \a values. |
|
2774 |
||
2775 |
\sa setAttributeValue() |
|
2776 |
*/ |
|
2777 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *values, int count) |
|
2778 |
{ |
|
2779 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2780 |
} |
|
2781 |
||
2782 |
// We have to repack matrix arrays from qreal to GLfloat. |
|
2783 |
#define setUniformMatrixArray(func,location,values,count,type,cols,rows) \ |
|
2784 |
if (location == -1 || count <= 0) \ |
|
2785 |
return; \ |
|
2786 |
if (sizeof(type) == sizeof(GLfloat) * cols * rows) { \ |
|
2787 |
func(location, count, GL_FALSE, \ |
|
2788 |
reinterpret_cast<const GLfloat *>(values[0].constData())); \ |
|
2789 |
} else { \ |
|
2790 |
QVarLengthArray<GLfloat> temp(cols * rows * count); \ |
|
2791 |
for (int index = 0; index < count; ++index) { \ |
|
2792 |
for (int index2 = 0; index2 < (cols * rows); ++index2) { \ |
|
2793 |
temp.data()[cols * rows * index + index2] = \ |
|
2794 |
values[index].constData()[index2]; \ |
|
2795 |
} \ |
|
2796 |
} \ |
|
2797 |
func(location, count, GL_FALSE, temp.constData()); \ |
|
2798 |
} |
|
2799 |
#if !defined(QT_OPENGL_ES_2) |
|
2800 |
#define setUniformGenericMatrixArray(func,colfunc,location,values,count,type,cols,rows) \ |
|
2801 |
if (location == -1 || count <= 0) \ |
|
2802 |
return; \ |
|
2803 |
if (sizeof(type) == sizeof(GLfloat) * cols * rows) { \ |
|
2804 |
const GLfloat *data = reinterpret_cast<const GLfloat *> \ |
|
2805 |
(values[0].constData()); \ |
|
2806 |
if (func) \ |
|
2807 |
func(location, count, GL_FALSE, data); \ |
|
2808 |
else \ |
|
2809 |
colfunc(location, count * cols, data); \ |
|
2810 |
} else { \ |
|
2811 |
QVarLengthArray<GLfloat> temp(cols * rows * count); \ |
|
2812 |
for (int index = 0; index < count; ++index) { \ |
|
2813 |
for (int index2 = 0; index2 < (cols * rows); ++index2) { \ |
|
2814 |
temp.data()[cols * rows * index + index2] = \ |
|
2815 |
values[index].constData()[index2]; \ |
|
2816 |
} \ |
|
2817 |
} \ |
|
2818 |
if (func) \ |
|
2819 |
func(location, count, GL_FALSE, temp.constData()); \ |
|
2820 |
else \ |
|
2821 |
colfunc(location, count * cols, temp.constData()); \ |
|
2822 |
} |
|
2823 |
#else |
|
2824 |
#define setUniformGenericMatrixArray(func,colfunc,location,values,count,type,cols,rows) \ |
|
2825 |
if (location == -1 || count <= 0) \ |
|
2826 |
return; \ |
|
2827 |
if (sizeof(type) == sizeof(GLfloat) * cols * rows) { \ |
|
2828 |
const GLfloat *data = reinterpret_cast<const GLfloat *> \ |
|
2829 |
(values[0].constData()); \ |
|
2830 |
colfunc(location, count * cols, data); \ |
|
2831 |
} else { \ |
|
2832 |
QVarLengthArray<GLfloat> temp(cols * rows * count); \ |
|
2833 |
for (int index = 0; index < count; ++index) { \ |
|
2834 |
for (int index2 = 0; index2 < (cols * rows); ++index2) { \ |
|
2835 |
temp.data()[cols * rows * index + index2] = \ |
|
2836 |
values[index].constData()[index2]; \ |
|
2837 |
} \ |
|
2838 |
} \ |
|
2839 |
colfunc(location, count * cols, temp.constData()); \ |
|
2840 |
} |
|
2841 |
#endif |
|
2842 |
||
2843 |
/*! |
|
2844 |
Sets the uniform variable array at \a location in the current |
|
2845 |
context to the \a count 2x2 matrix elements of \a values. |
|
2846 |
||
2847 |
\sa setAttributeValue() |
|
2848 |
*/ |
|
2849 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count) |
|
2850 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2851 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2852 |
Q_UNUSED(d); |
0 | 2853 |
setUniformMatrixArray |
2854 |
(glUniformMatrix2fv, location, values, count, QMatrix2x2, 2, 2); |
|
2855 |
} |
|
2856 |
||
2857 |
/*! |
|
2858 |
\overload |
|
2859 |
||
2860 |
Sets the uniform variable array called \a name in the current |
|
2861 |
context to the \a count 2x2 matrix elements of \a values. |
|
2862 |
||
2863 |
\sa setAttributeValue() |
|
2864 |
*/ |
|
2865 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 *values, int count) |
|
2866 |
{ |
|
2867 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2868 |
} |
|
2869 |
||
2870 |
/*! |
|
2871 |
Sets the uniform variable array at \a location in the current |
|
2872 |
context to the \a count 2x3 matrix elements of \a values. |
|
2873 |
||
2874 |
\sa setAttributeValue() |
|
2875 |
*/ |
|
2876 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count) |
|
2877 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2878 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2879 |
Q_UNUSED(d); |
0 | 2880 |
setUniformGenericMatrixArray |
2881 |
(glUniformMatrix2x3fv, glUniform3fv, location, values, count, |
|
2882 |
QMatrix2x3, 2, 3); |
|
2883 |
} |
|
2884 |
||
2885 |
/*! |
|
2886 |
\overload |
|
2887 |
||
2888 |
Sets the uniform variable array called \a name in the current |
|
2889 |
context to the \a count 2x3 matrix elements of \a values. |
|
2890 |
||
2891 |
\sa setAttributeValue() |
|
2892 |
*/ |
|
2893 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 *values, int count) |
|
2894 |
{ |
|
2895 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2896 |
} |
|
2897 |
||
2898 |
/*! |
|
2899 |
Sets the uniform variable array at \a location in the current |
|
2900 |
context to the \a count 2x4 matrix elements of \a values. |
|
2901 |
||
2902 |
\sa setAttributeValue() |
|
2903 |
*/ |
|
2904 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count) |
|
2905 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2906 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2907 |
Q_UNUSED(d); |
0 | 2908 |
setUniformGenericMatrixArray |
2909 |
(glUniformMatrix2x4fv, glUniform4fv, location, values, count, |
|
2910 |
QMatrix2x4, 2, 4); |
|
2911 |
} |
|
2912 |
||
2913 |
/*! |
|
2914 |
\overload |
|
2915 |
||
2916 |
Sets the uniform variable array called \a name in the current |
|
2917 |
context to the \a count 2x4 matrix elements of \a values. |
|
2918 |
||
2919 |
\sa setAttributeValue() |
|
2920 |
*/ |
|
2921 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 *values, int count) |
|
2922 |
{ |
|
2923 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2924 |
} |
|
2925 |
||
2926 |
/*! |
|
2927 |
Sets the uniform variable array at \a location in the current |
|
2928 |
context to the \a count 3x2 matrix elements of \a values. |
|
2929 |
||
2930 |
\sa setAttributeValue() |
|
2931 |
*/ |
|
2932 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count) |
|
2933 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2934 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2935 |
Q_UNUSED(d); |
0 | 2936 |
setUniformGenericMatrixArray |
2937 |
(glUniformMatrix3x2fv, glUniform2fv, location, values, count, |
|
2938 |
QMatrix3x2, 3, 2); |
|
2939 |
} |
|
2940 |
||
2941 |
/*! |
|
2942 |
\overload |
|
2943 |
||
2944 |
Sets the uniform variable array called \a name in the current |
|
2945 |
context to the \a count 3x2 matrix elements of \a values. |
|
2946 |
||
2947 |
\sa setAttributeValue() |
|
2948 |
*/ |
|
2949 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 *values, int count) |
|
2950 |
{ |
|
2951 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2952 |
} |
|
2953 |
||
2954 |
/*! |
|
2955 |
Sets the uniform variable array at \a location in the current |
|
2956 |
context to the \a count 3x3 matrix elements of \a values. |
|
2957 |
||
2958 |
\sa setAttributeValue() |
|
2959 |
*/ |
|
2960 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count) |
|
2961 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2962 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2963 |
Q_UNUSED(d); |
0 | 2964 |
setUniformMatrixArray |
2965 |
(glUniformMatrix3fv, location, values, count, QMatrix3x3, 3, 3); |
|
2966 |
} |
|
2967 |
||
2968 |
/*! |
|
2969 |
\overload |
|
2970 |
||
2971 |
Sets the uniform variable array called \a name in the current |
|
2972 |
context to the \a count 3x3 matrix elements of \a values. |
|
2973 |
||
2974 |
\sa setAttributeValue() |
|
2975 |
*/ |
|
2976 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 *values, int count) |
|
2977 |
{ |
|
2978 |
setUniformValueArray(uniformLocation(name), values, count); |
|
2979 |
} |
|
2980 |
||
2981 |
/*! |
|
2982 |
Sets the uniform variable array at \a location in the current |
|
2983 |
context to the \a count 3x4 matrix elements of \a values. |
|
2984 |
||
2985 |
\sa setAttributeValue() |
|
2986 |
*/ |
|
2987 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count) |
|
2988 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2989 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
2990 |
Q_UNUSED(d); |
0 | 2991 |
setUniformGenericMatrixArray |
2992 |
(glUniformMatrix3x4fv, glUniform4fv, location, values, count, |
|
2993 |
QMatrix3x4, 3, 4); |
|
2994 |
} |
|
2995 |
||
2996 |
/*! |
|
2997 |
\overload |
|
2998 |
||
2999 |
Sets the uniform variable array called \a name in the current |
|
3000 |
context to the \a count 3x4 matrix elements of \a values. |
|
3001 |
||
3002 |
\sa setAttributeValue() |
|
3003 |
*/ |
|
3004 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 *values, int count) |
|
3005 |
{ |
|
3006 |
setUniformValueArray(uniformLocation(name), values, count); |
|
3007 |
} |
|
3008 |
||
3009 |
/*! |
|
3010 |
Sets the uniform variable array at \a location in the current |
|
3011 |
context to the \a count 4x2 matrix elements of \a values. |
|
3012 |
||
3013 |
\sa setAttributeValue() |
|
3014 |
*/ |
|
3015 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count) |
|
3016 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3017 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3018 |
Q_UNUSED(d); |
0 | 3019 |
setUniformGenericMatrixArray |
3020 |
(glUniformMatrix4x2fv, glUniform2fv, location, values, count, |
|
3021 |
QMatrix4x2, 4, 2); |
|
3022 |
} |
|
3023 |
||
3024 |
/*! |
|
3025 |
\overload |
|
3026 |
||
3027 |
Sets the uniform variable array called \a name in the current |
|
3028 |
context to the \a count 4x2 matrix elements of \a values. |
|
3029 |
||
3030 |
\sa setAttributeValue() |
|
3031 |
*/ |
|
3032 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 *values, int count) |
|
3033 |
{ |
|
3034 |
setUniformValueArray(uniformLocation(name), values, count); |
|
3035 |
} |
|
3036 |
||
3037 |
/*! |
|
3038 |
Sets the uniform variable array at \a location in the current |
|
3039 |
context to the \a count 4x3 matrix elements of \a values. |
|
3040 |
||
3041 |
\sa setAttributeValue() |
|
3042 |
*/ |
|
3043 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count) |
|
3044 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3045 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3046 |
Q_UNUSED(d); |
0 | 3047 |
setUniformGenericMatrixArray |
3048 |
(glUniformMatrix4x3fv, glUniform3fv, location, values, count, |
|
3049 |
QMatrix4x3, 4, 3); |
|
3050 |
} |
|
3051 |
||
3052 |
/*! |
|
3053 |
\overload |
|
3054 |
||
3055 |
Sets the uniform variable array called \a name in the current |
|
3056 |
context to the \a count 4x3 matrix elements of \a values. |
|
3057 |
||
3058 |
\sa setAttributeValue() |
|
3059 |
*/ |
|
3060 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 *values, int count) |
|
3061 |
{ |
|
3062 |
setUniformValueArray(uniformLocation(name), values, count); |
|
3063 |
} |
|
3064 |
||
3065 |
/*! |
|
3066 |
Sets the uniform variable array at \a location in the current |
|
3067 |
context to the \a count 4x4 matrix elements of \a values. |
|
3068 |
||
3069 |
\sa setAttributeValue() |
|
3070 |
*/ |
|
3071 |
void QGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count) |
|
3072 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3073 |
Q_D(QGLShaderProgram); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3074 |
Q_UNUSED(d); |
0 | 3075 |
setUniformMatrixArray |
3076 |
(glUniformMatrix4fv, location, values, count, QMatrix4x4, 4, 4); |
|
3077 |
} |
|
3078 |
||
3079 |
/*! |
|
3080 |
\overload |
|
3081 |
||
3082 |
Sets the uniform variable array called \a name in the current |
|
3083 |
context to the \a count 4x4 matrix elements of \a values. |
|
3084 |
||
3085 |
\sa setAttributeValue() |
|
3086 |
*/ |
|
3087 |
void QGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x4 *values, int count) |
|
3088 |
{ |
|
3089 |
setUniformValueArray(uniformLocation(name), values, count); |
|
3090 |
} |
|
3091 |
||
3092 |
#undef ctx |
|
3093 |
||
3094 |
/*! |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3095 |
Returns the hardware limit for how many vertices a geometry shader |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3096 |
can output. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3097 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3098 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3099 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3100 |
\sa setGeometryOutputVertexCount() |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3101 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3102 |
int QGLShaderProgram::maxGeometryOutputVertices() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3103 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3104 |
GLint n; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3105 |
glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &n); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3106 |
return n; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3107 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3108 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3109 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3110 |
Sets the maximum number of vertices the current geometry shader |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3111 |
program will produce, if active, to \a count. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3112 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3113 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3114 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3115 |
This parameter takes effect the next time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3116 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3117 |
void QGLShaderProgram::setGeometryOutputVertexCount(int count) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3118 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3119 |
#ifndef QT_NO_DEBUG |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3120 |
int max = maxGeometryOutputVertices(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3121 |
if (count > max) { |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3122 |
qWarning("QGLShaderProgram::setGeometryOutputVertexCount: count: %d higher than maximum: %d", |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3123 |
count, max); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3124 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3125 |
#endif |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3126 |
d_func()->geometryVertexCount = count; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3127 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3128 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3129 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3130 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3131 |
Returns the maximum number of vertices the current geometry shader |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3132 |
program will produce, if active. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3133 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3134 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3135 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3136 |
This parameter takes effect the ntext time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3137 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3138 |
int QGLShaderProgram::geometryOutputVertexCount() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3139 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3140 |
return d_func()->geometryVertexCount; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3141 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3142 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3143 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3144 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3145 |
Sets the input type from \a inputType. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3146 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3147 |
This parameter takes effect the next time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3148 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3149 |
void QGLShaderProgram::setGeometryInputType(GLenum inputType) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3150 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3151 |
d_func()->geometryInputType = inputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3152 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3153 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3154 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3155 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3156 |
Returns the geometry shader input type, if active. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3157 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3158 |
This parameter takes effect the next time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3159 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3160 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3161 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3162 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3163 |
GLenum QGLShaderProgram::geometryInputType() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3164 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3165 |
return d_func()->geometryInputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3166 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3167 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3168 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3169 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3170 |
Sets the output type from the geometry shader, if active, to |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3171 |
\a outputType. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3172 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3173 |
This parameter takes effect the next time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3174 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3175 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3176 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3177 |
void QGLShaderProgram::setGeometryOutputType(GLenum outputType) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3178 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3179 |
d_func()->geometryOutputType = outputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3180 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3181 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3182 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3183 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3184 |
Returns the geometry shader output type, if active. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3185 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3186 |
This parameter takes effect the next time the program is linked. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3187 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3188 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3189 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3190 |
GLenum QGLShaderProgram::geometryOutputType() const |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3191 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3192 |
return d_func()->geometryOutputType; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3193 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3194 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3195 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3196 |
/*! |
0 | 3197 |
Returns true if shader programs written in the OpenGL Shading |
3198 |
Language (GLSL) are supported on this system; false otherwise. |
|
3199 |
||
3200 |
The \a context is used to resolve the GLSL extensions. |
|
3201 |
If \a context is null, then QGLContext::currentContext() is used. |
|
3202 |
*/ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3203 |
bool QGLShaderProgram::hasOpenGLShaderPrograms(const QGLContext *context) |
0 | 3204 |
{ |
3205 |
#if !defined(QT_OPENGL_ES_2) |
|
3206 |
if (!context) |
|
3207 |
context = QGLContext::currentContext(); |
|
3208 |
if (!context) |
|
3209 |
return false; |
|
3210 |
return qt_resolve_glsl_extensions(const_cast<QGLContext *>(context)); |
|
3211 |
#else |
|
3212 |
Q_UNUSED(context); |
|
3213 |
return true; |
|
3214 |
#endif |
|
3215 |
} |
|
3216 |
||
3217 |
/*! |
|
3218 |
\internal |
|
3219 |
*/ |
|
3220 |
void QGLShaderProgram::shaderDestroyed() |
|
3221 |
{ |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3222 |
Q_D(QGLShaderProgram); |
0 | 3223 |
QGLShader *shader = qobject_cast<QGLShader *>(sender()); |
3224 |
if (shader && !d->removingShaders) |
|
3225 |
removeShader(shader); |
|
3226 |
} |
|
3227 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3228 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3229 |
#undef ctx |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3230 |
#undef context |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3231 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3232 |
/*! |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3233 |
Returns true if shader programs of type \a type are supported on |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3234 |
this system; false otherwise. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3235 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3236 |
The \a context is used to resolve the GLSL extensions. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3237 |
If \a context is null, then QGLContext::currentContext() is used. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3238 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3239 |
\since 4.7 |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3240 |
*/ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3241 |
bool QGLShader::hasOpenGLShaders(ShaderType type, const QGLContext *context) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3242 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3243 |
if (!context) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3244 |
context = QGLContext::currentContext(); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3245 |
if (!context) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3246 |
return false; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3247 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3248 |
if ((type & ~(Geometry | Vertex | Fragment)) || type == 0) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3249 |
return false; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3250 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3251 |
bool resolved = qt_resolve_glsl_extensions(const_cast<QGLContext *>(context)); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3252 |
if (!resolved) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3253 |
return false; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3254 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3255 |
if ((type & Geometry) && !QByteArray((const char *) glGetString(GL_EXTENSIONS)).contains("GL_EXT_geometry_shader4")) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3256 |
return false; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3257 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3258 |
return true; |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3259 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3260 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3261 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3262 |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3263 |
#ifdef Q_MAC_COMPAT_GL_FUNCTIONS |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3264 |
/*! \internal */ |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3265 |
void QGLShaderProgram::setAttributeArray |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3266 |
(int location, QMacCompatGLenum type, const void *values, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3267 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3268 |
setAttributeArray(location, GLenum(type), values, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3269 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3270 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3271 |
/*! \internal */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3272 |
void QGLShaderProgram::setAttributeArray |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3273 |
(const char *name, QMacCompatGLenum type, const void *values, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3274 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3275 |
setAttributeArray(name, GLenum(type), values, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3276 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3277 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3278 |
/*! \internal */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3279 |
void QGLShaderProgram::setAttributeBuffer |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3280 |
(int location, QMacCompatGLenum type, int offset, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3281 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3282 |
setAttributeBuffer(location, GLenum(type), offset, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3283 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3284 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3285 |
/*! \internal */ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3286 |
void QGLShaderProgram::setAttributeBuffer |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3287 |
(const char *name, QMacCompatGLenum type, int offset, int tupleSize, int stride) |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3288 |
{ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3289 |
setAttributeBuffer(name, GLenum(type), offset, tupleSize, stride); |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3290 |
} |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3291 |
|
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3292 |
/*! \internal */ |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3293 |
void QGLShaderProgram::setUniformValue(int location, QMacCompatGLint value) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3294 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3295 |
setUniformValue(location, GLint(value)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3296 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3297 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3298 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3299 |
void QGLShaderProgram::setUniformValue(int location, QMacCompatGLuint value) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3300 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3301 |
setUniformValue(location, GLuint(value)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3302 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3303 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3304 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3305 |
void QGLShaderProgram::setUniformValue(const char *name, QMacCompatGLint value) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3306 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3307 |
setUniformValue(name, GLint(value)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3308 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3309 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3310 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3311 |
void QGLShaderProgram::setUniformValue(const char *name, QMacCompatGLuint value) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3312 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3313 |
setUniformValue(name, GLuint(value)); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3314 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3315 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3316 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3317 |
void QGLShaderProgram::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
|
3318 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3319 |
setUniformValueArray(location, (const GLint *)values, count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3320 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3321 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3322 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3323 |
void QGLShaderProgram::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
|
3324 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3325 |
setUniformValueArray(location, (const GLuint *)values, count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3326 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3327 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3328 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3329 |
void QGLShaderProgram::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
|
3330 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3331 |
setUniformValueArray(name, (const GLint *)values, count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3332 |
} |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3333 |
|
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3334 |
/*! \internal */ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3335 |
void QGLShaderProgram::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
|
3336 |
{ |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3337 |
setUniformValueArray(name, (const GLuint *)values, count); |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3338 |
} |
0 | 3339 |
#endif |
3340 |
||
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
22
diff
changeset
|
3341 |
#endif // !defined(QT_OPENGL_ES_1) |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3342 |
|
0 | 3343 |
QT_END_NAMESPACE |