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