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

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