OpenCoverage

qopenglshaderprogram.cpp

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

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9