qopenglshaderprogram.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopenglshaderprogram.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8class QOpenGLShaderPrivate : public QObjectPrivate-
9{-
10 inline QOpenGLShader* q_func() { return static_cast<QOpenGLShader *>(q_ptr); } inline const QOpenGLShader* q_func() const { return static_cast<const QOpenGLShader *>(q_ptr); } friend class QOpenGLShader;-
11public:-
12 QOpenGLShaderPrivate(QOpenGLContext *ctx, QOpenGLShader::ShaderType type)-
13 : shaderGuard(0)-
14 , shaderType(type)-
15 , compiled(false)-
16 , glfuncs(new QOpenGLFunctions(ctx))-
17-
18 , supportsGeometryShaders(false)-
19 , supportsTessellationShaders(false)-
20-
21 {-
22-
23 if (!ctx->isOpenGLES()) {-
24 QSurfaceFormat f = ctx->format();-
25-
26-
27 if (shaderType & QOpenGLShader::Geometry)-
28 supportsGeometryShaders = (f.version() >= qMakePair<int, int>(3, 2));-
29 else if (shaderType & (QOpenGLShader::TessellationControl | QOpenGLShader::TessellationEvaluation))-
30 supportsTessellationShaders = (f.version() >= qMakePair<int, int>(4, 0));-
31 }-
32-
33 }-
34 ~QOpenGLShaderPrivate();-
35-
36 QOpenGLSharedResourceGuard *shaderGuard;-
37 QOpenGLShader::ShaderType shaderType;-
38 bool compiled;-
39 QString log;-
40-
41 QOpenGLFunctions *glfuncs;-
42-
43-
44-
45 bool supportsGeometryShaders;-
46-
47-
48 bool supportsTessellationShaders;-
49-
50-
51 bool create();-
52 bool compile(QOpenGLShader *q);-
53 void deleteShader();-
54};-
55-
56namespace {-
57 void freeShaderFunc(QOpenGLFunctions *funcs, GLuint id)-
58 {-
59 funcs->glDeleteShader(id);-
60 }-
61}-
62-
63QOpenGLShaderPrivate::~QOpenGLShaderPrivate()-
64{-
65 delete glfuncs;-
66 if (shaderGuard)-
67 shaderGuard->free();-
68}-
69-
70bool QOpenGLShaderPrivate::create()-
71{-
72 QOpenGLContext *context = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
73 if (!context
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
74 return
never executed: return false;
false;
never executed: return false;
0
75 GLuint shader;-
76 if (shaderType == QOpenGLShader::Vertex
shaderType == ...Shader::VertexDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
77 shader = glfuncs->glCreateShader(0x8B31);-
78-
79 }
never executed: end of block
else if (shaderType == QOpenGLShader::Geometry
shaderType == ...ader::GeometryDescription
TRUEnever evaluated
FALSEnever evaluated
&& supportsGeometryShaders
supportsGeometryShadersDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
80 shader = glfuncs->glCreateShader(0x8DD9);-
81-
82-
83 }
never executed: end of block
else if (shaderType == QOpenGLShader::TessellationControl
shaderType == ...llationControlDescription
TRUEnever evaluated
FALSEnever evaluated
&& supportsTessellationShaders
supportsTessellationShadersDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
84 shader = glfuncs->glCreateShader(0x8E88);-
85 }
never executed: end of block
else if (shaderType == QOpenGLShader::TessellationEvaluation
shaderType == ...tionEvaluationDescription
TRUEnever evaluated
FALSEnever evaluated
&& supportsTessellationShaders
supportsTessellationShadersDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
86 shader = glfuncs->glCreateShader(0x8E87);-
87-
88-
89 }
never executed: end of block
else if (shaderType == QOpenGLShader::Compute
shaderType == ...hader::ComputeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
90 shader = glfuncs->glCreateShader(0x91B9);-
91-
92 }
never executed: end of block
else {
0
93 shader = glfuncs->glCreateShader(0x8B30);-
94 }
never executed: end of block
0
95 if (!shader
!shaderDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
96 QMessageLogger(__FILE__, 247253, __PRETTY_FUNCTION__).warning() << ("QOpenGLShader: could not create shader";);-
97 return
never executed: return false;
false;
never executed: return false;
0
98 }-
99 shaderGuard = new QOpenGLSharedResourceGuard(context, shader, freeShaderFunc);-
100 return
never executed: return true;
true;
never executed: return true;
0
101}-
102-
103bool QOpenGLShaderPrivate::compile(QOpenGLShader *q)-
104{-
105 GLuint shader = shaderGuard ? shaderGuard->id() : 0;-
106 if (!shader)-
107 return false;-
108-
109-
110 glfuncs->glCompileShader(shader);-
111 GLint value = 0;-
112-
113-
114 glfuncs->glGetShaderiv(shader, 0x8B81, &value);-
115 compiled = (value != 0);-
116-
117 if (!compiled) {-
118-
119 QString name = q->objectName();-
120-
121 const char *types[] = {-
122 "Fragment",-
123 "Vertex",-
124 "Geometry",-
125 "Tessellation Control",-
126 "Tessellation Evaluation",-
127 "Compute",-
128 ""-
129 };-
130-
131 const char *type = types[6];-
132 switch (shaderType) {-
133 case QOpenGLShader::Fragment:-
134 type = types[0]; break;-
135 case QOpenGLShader::Vertex:-
136 type = types[1]; break;-
137 case QOpenGLShader::Geometry:-
138 type = types[2]; break;-
139 case QOpenGLShader::TessellationControl:-
140 type = types[3]; break;-
141 case QOpenGLShader::TessellationEvaluation:-
142 type = types[4]; break;-
143 case QOpenGLShader::Compute:-
144 type = types[5]; break;-
145 }-
146-
147-
148 GLint infoLogLength = 0;-
149 GLint sourceCodeLength = 0;-
150 char *logBuffer = 0;-
151 char *sourceCodeBuffer = 0;-
152-
153-
154 glfuncs->glGetShaderiv(shader, 0x8B84, &infoLogLength);-
155-
156 if (infoLogLength > 1) {-
157 GLint temp;-
158 logBuffer = new char [infoLogLength];-
159 glfuncs->glGetShaderInfoLog(shader, infoLogLength, &temp, logBuffer);-
160 }-
161-
162-
163 glfuncs->glGetShaderiv(shader, 0x8B88, &sourceCodeLength);-
164-
165 if (sourceCodeLength > 1) {-
166 GLint temp;-
167 sourceCodeBuffer = new char [sourceCodeLength];-
168 glfuncs->glGetShaderSource(shader, sourceCodeLength, &temp, sourceCodeBuffer);-
169 }-
170-
171 if (logBuffer)-
172 log = QString::fromLatin1(logBuffer);-
173 else-
174 log = QLatin1String("failed");-
175-
176 if (name.isEmpty())-
177 QMessageLogger(__FILE__, 328334, __PRETTY_FUNCTION__).warning("QOpenGLShader::compile(%s): %s", type, QString(log).toLocal8Bit().constData());-
178 else-
179 QMessageLogger(__FILE__, 330336, __PRETTY_FUNCTION__).warning("QOpenGLShader::compile(%s)[%s]: %s", type, QString(name).toLocal8Bit().constData(), QString(log).toLocal8Bit().constData());-
180-
181-
182 if (sourceCodeBuffer) {-
183 QMessageLogger(__FILE__, 334340, __PRETTY_FUNCTION__).warning("*** Problematic %s shader source code ***", type);-
184 QMessageLogger(__FILE__, 335341, __PRETTY_FUNCTION__).warning() << QString(QString::fromLatin1(sourceCodeBuffer)).toLocal8Bit().constData();-
185 QMessageLogger(__FILE__, 336342, __PRETTY_FUNCTION__).warning("***");-
186 }-
187-
188-
189 delete [] logBuffer;-
190 delete [] sourceCodeBuffer;-
191 }-
192-
193 return compiled;-
194}-
195-
196void QOpenGLShaderPrivate::deleteShader()-
197{-
198 if (shaderGuard) {-
199 shaderGuard->free();-
200 shaderGuard = 0;-
201 }-
202}-
203QOpenGLShader::QOpenGLShader(QOpenGLShader::ShaderType type, QObject *parent)-
204 : QObject(*new QOpenGLShaderPrivate(QOpenGLContext::currentContext(), type), parent)-
205{-
206 QOpenGLShaderPrivate * const d = d_func();-
207 d->create();-
208}-
209-
210-
211-
212-
213-
214-
215QOpenGLShader::~QOpenGLShader()-
216{-
217}-
218-
219-
220-
221-
222QOpenGLShader::ShaderType QOpenGLShader::shaderType() const-
223{-
224 const QOpenGLShaderPrivate * const d = d_func();-
225 return d->shaderType;-
226}-
227-
228static const char qualifierDefines[] =-
229 "#define lowp\n"-
230 "#define mediump\n"-
231 "#define highp\n";-
232struct QVersionDirectivePosition-
233{-
234 constexpr QVersionDirectivePosition(int position = 0, int line = -1)-
235 : position(position)-
236 , line(line)-
237 {-
238 }-
239-
240 constexpr bool hasPosition() const-
241 {-
242 return position > 0;-
243 }-
244-
245 const int position;-
246 const int line;-
247};-
248-
249static QVersionDirectivePosition findVersionDirectivePosition(const char *source)-
250{-
251 ((!(source)) ? qt_assert("source",__FILE__,426432) : qt_noop());-
252-
253 QString working = QString::fromUtf8(source);-
254-
255-
256-
257-
258-
259 enum {-
260 Normal,-
261 CommentStarting,-
262 MultiLineComment,-
263 SingleLineComment,-
264 CommentEnding-
265 } state = Normal;-
266-
267 for (QChar *c = working.begin(); c != working.end(); ++c) {-
268 switch (state) {-
269 case Normal:-
270 if (*c == QLatin1Char('/'))-
271 state = CommentStarting;-
272 break;-
273 case CommentStarting:-
274 if (*c == QLatin1Char('*'))-
275 state = MultiLineComment;-
276 else if (*c == QLatin1Char('/'))-
277 state = SingleLineComment;-
278 else-
279 state = Normal;-
280 break;-
281 case MultiLineComment:-
282 if (*c == QLatin1Char('*'))-
283 state = CommentEnding;-
284 else if (*c == QLatin1Char('#'))-
285 *c = QLatin1Char('_');-
286 break;-
287 case SingleLineComment:-
288 if (*c == QLatin1Char('\n'))-
289 state = Normal;-
290 else if (*c == QLatin1Char('#'))-
291 *c = QLatin1Char('_');-
292 break;-
293 case CommentEnding:-
294 if (*c == QLatin1Char('/')) {-
295 state = Normal;-
296 } else {-
297 if (*c == QLatin1Char('#'))-
298 *c = QLatin1Char('_');-
299 if (*c != QLatin1Char('*'))-
300 state = MultiLineComment;-
301 }-
302 break;-
303 }-
304 }-
305-
306-
307 int splitPosition = 0;-
308 int linePosition = 1;-
309-
310 static const QRegularExpression pattern(([]() -> QString { enum { Size = sizeof(u"" "^\\s*#\\s*version.*(\\n)?")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "^\\s*#\\s*version.*(\\n)?" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()),-
311 QRegularExpression::MultilineOption-
312 | QRegularExpression::OptimizeOnFirstUsageOption);-
313 QRegularExpressionMatch match = pattern.match(working);-
314 if (match.hasMatch()) {-
315 splitPosition = match.capturedEnd();-
316 linePosition += int(std::count(working.begin(), working.begin() + splitPosition, QLatin1Char('\n')));-
317 }-
318-
319 return QVersionDirectivePosition(splitPosition, linePosition);-
320}-
321-
322-
323-
324-
325-
326-
327-
328bool QOpenGLShader::compileSourceCode(const char *source)-
329{-
330 QOpenGLShaderPrivate * const d = d_func();-
331 if (d->shaderGuard && d->shaderGuard->id() && source) {-
332 const QVersionDirectivePosition versionDirectivePosition = findVersionDirectivePosition(source);-
333-
334 QVarLengthArray<const char *, 5> sourceChunks;-
335 QVarLengthArray<GLint, 5> sourceChunkLengths;-
336 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
337-
338 if (versionDirectivePosition.hasPosition()) {-
339-
340 sourceChunks.append(source);-
341 sourceChunkLengths.append(GLint(versionDirectivePosition.position));-
342 } else {-
343-
344 if (ctx->format().profile() == QSurfaceFormat::CompatibilityProfile) {-
345 const char *vendor = reinterpret_cast<const char *>(ctx->functions()->glGetString(0x1F00));-
346 if (vendor && !strcmp(vendor, "Intel")) {-
347 static const char version110[] = "#version 110\n";-
348 sourceChunks.append(version110);-
349 sourceChunkLengths.append(GLint(sizeof(version110)) - 1);-
350 }-
351 }-
352 }-
353-
354-
355-
356 const QSurfaceFormat currentSurfaceFormat = ctx->format();-
357 QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(QOpenGLContext::currentContext());-
358 if (currentSurfaceFormat.renderableType() == QSurfaceFormat::OpenGL-
359 || ctx_d->workaround_missingPrecisionQualifiers-
360-
361-
362-
363 ) {-
364 sourceChunks.append(qualifierDefines);-
365 sourceChunkLengths.append(GLint(sizeof(qualifierDefines) - 1));-
366 }-
367 QByteArray lineDirective;-
368-
369-
370 const char *version = reinterpret_cast<const char *>(ctx->functions()->glGetString(0x1F02));-
371 if (!version || !strstr(version, "2.1 Mesa 8")) {-
372-
373 lineDirective = ([]() -> QString { enum { Size = sizeof(u"" "#line %1\n")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "#line %1\n" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }()).arg(versionDirectivePosition.line).toUtf8();-
374 sourceChunks.append(lineDirective.constData());-
375 sourceChunkLengths.append(GLint(lineDirective.length()));-
376 }-
377-
378-
379 sourceChunks.append(source + versionDirectivePosition.position);-
380 sourceChunkLengths.append(GLint(qstrlen(source + versionDirectivePosition.position)));-
381-
382 d->glfuncs->glShaderSource(d->shaderGuard->id(), sourceChunks.size(), sourceChunks.data(), sourceChunkLengths.data());-
383 return d->compile(this);-
384 } else {-
385 return false;-
386 }-
387}-
388bool QOpenGLShader::compileSourceCode(const QByteArray& source)-
389{-
390 return compileSourceCode(source.constData());-
391}-
392bool QOpenGLShader::compileSourceCode(const QString& source)-
393{-
394 return compileSourceCode(source.toLatin1().constData());-
395}-
396bool QOpenGLShader::compileSourceFile(const QString& fileName)-
397{-
398 QFile file(fileName);-
399 if (!file.open(QFile::ReadOnly)) {-
400 QMessageLogger(__FILE__, 618624, __PRETTY_FUNCTION__).warning() << "QOpenGLShader: Unable to open file" << fileName;-
401 return false;-
402 }-
403-
404 QByteArray contents = file.readAll();-
405 return compileSourceCode(contents.constData());-
406}-
407-
408-
409-
410-
411-
412-
413QByteArray QOpenGLShader::sourceCode() const-
414{-
415 const QOpenGLShaderPrivate * const d = d_func();-
416 GLuint shader = d->shaderGuard ? d->shaderGuard->id() : 0;-
417 if (!shader)-
418 return QByteArray();-
419 GLint size = 0;-
420 d->glfuncs->glGetShaderiv(shader, 0x8B88, &size);-
421 if (size <= 0)-
422 return QByteArray();-
423 GLint len = 0;-
424 char *source = new char [size];-
425 d->glfuncs->glGetShaderSource(shader, size, &len, source);-
426 QByteArray src(source);-
427 delete [] source;-
428 return src;-
429}-
430-
431-
432-
433-
434-
435-
436bool QOpenGLShader::isCompiled() const-
437{-
438 const QOpenGLShaderPrivate * const d = d_func();-
439 return d->compiled;-
440}-
441-
442-
443-
444-
445-
446-
447QString QOpenGLShader::log() const-
448{-
449 const QOpenGLShaderPrivate * const d = d_func();-
450 return d->log;-
451}-
452-
453-
454-
455-
456-
457-
458GLuint QOpenGLShader::shaderId() const-
459{-
460 const QOpenGLShaderPrivate * const d = d_func();-
461 return d->shaderGuard ? d->shaderGuard->id() : 0;-
462}-
463-
464class QOpenGLShaderProgramPrivate : public QObjectPrivate-
465{-
466 inline QOpenGLShaderProgram* q_func() { return static_cast<QOpenGLShaderProgram *>(q_ptr); } inline const QOpenGLShaderProgram* q_func() const { return static_cast<const QOpenGLShaderProgram *>(q_ptr); } friend class QOpenGLShaderProgram;-
467public:-
468 QOpenGLShaderProgramPrivate()-
469 : programGuard(0)-
470 , linked(false)-
471 , inited(false)-
472 , removingShaders(false)-
473 , glfuncs(new QOpenGLFunctions)-
474-
475 , tessellationFuncs(0)-
476-
477 {-
478 }-
479 ~QOpenGLShaderProgramPrivate();-
480-
481 QOpenGLSharedResourceGuard *programGuard;-
482 bool linked;-
483 bool inited;-
484 bool removingShaders;-
485-
486 QString log;-
487 QList<QOpenGLShader *> shaders;-
488 QList<QOpenGLShader *> anonShaders;-
489-
490 QOpenGLFunctions *glfuncs;-
491-
492-
493-
494 QOpenGLFunctions_4_0_Core *tessellationFuncs;-
495-
496-
497 bool hasShader(QOpenGLShader::ShaderType type) const;-
498};-
499-
500namespace {-
501 void freeProgramFunc(QOpenGLFunctions *funcs, GLuint id)-
502 {-
503 funcs->glDeleteProgram(id);-
504 }-
505}-
506-
507-
508QOpenGLShaderProgramPrivate::~QOpenGLShaderProgramPrivate()-
509{-
510 delete glfuncs;-
511 if (programGuard)-
512 programGuard->free();-
513}-
514-
515bool QOpenGLShaderProgramPrivate::hasShader(QOpenGLShader::ShaderType type) const-
516{-
517 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(shaders)>::type> _container_((shaders)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1)for (QOpenGLShader *shader = *_container_.i; _container_.control; _container_.control = 0: shaders) {-
518 if (shader->shaderType() == type
shader->shaderType() == typeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
519 return
never executed: return true;
true;
never executed: return true;
0
520 }
never executed: end of block
0
521 return
never executed: return false;
false;
never executed: return false;
0
522}-
523QOpenGLShaderProgram::QOpenGLShaderProgram(QObject *parent)-
524 : QObject(*new QOpenGLShaderProgramPrivate, parent)-
525{-
526}-
527-
528-
529-
530-
531QOpenGLShaderProgram::~QOpenGLShaderProgram()-
532{-
533}-
534bool QOpenGLShaderProgram::create()-
535{-
536 return init();-
537}-
538-
539bool QOpenGLShaderProgram::init()-
540{-
541 QOpenGLShaderProgramPrivate * const d = d_func();-
542 if ((d->programGuard
d->programGuardDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->programGuard->id()
d->programGuard->id()Description
TRUEnever evaluated
FALSEnever evaluated
) || d->inited
d->initedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
543 return
never executed: return true;
true;
never executed: return true;
0
544 d->inited = true;-
545 QOpenGLContext *context = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());-
546 if (!context
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
547 return
never executed: return false;
false;
never executed: return false;
0
548 d->glfuncs->initializeOpenGLFunctions();-
549-
550-
551-
552 QSurfaceFormat format = context->format();-
553 if (!context->isOpenGLES()
!context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
0
554 && format.version() >= qMakePair<int, int>(4, 0)
format.version...nt, int>(4, 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
555 d->tessellationFuncs = context->versionFunctions<QOpenGLFunctions_4_0_Core>();-
556 d->tessellationFuncs->initializeOpenGLFunctions();-
557 }
never executed: end of block
0
558-
559-
560 GLuint program = d->glfuncs->glCreateProgram();-
561 if (!program
!programDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
562 QMessageLogger(__FILE__, 805811, __PRETTY_FUNCTION__).warning() << ("QOpenGLShaderProgram: could not create shader program";);-
563 return
never executed: return false;
false;
never executed: return false;
0
564 }-
565 if (d->programGuard
d->programGuardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
566 delete d->programGuard;
never executed: delete d->programGuard;
0
567 d->programGuard = new QOpenGLSharedResourceGuard(context, program, freeProgramFunc);-
568 return
never executed: return true;
true;
never executed: return true;
0
569}-
570bool QOpenGLShaderProgram::addShader(QOpenGLShader *shader)-
571{-
572 QOpenGLShaderProgramPrivate * const d = d_func();-
573 if (!init())-
574 return false;-
575 if (d->shaders.contains(shader))-
576 return true;-
577 if (d->programGuard && d->programGuard->id() && shader) {-
578 if (!shader->d_func()->shaderGuard || !shader->d_func()->shaderGuard->id())-
579 return false;-
580 if (d->programGuard->group() != shader->d_func()->shaderGuard->group()) {-
581 QMessageLogger(__FILE__, 837843, __PRETTY_FUNCTION__).warning("QOpenGLShaderProgram::addShader: Program and shader are not associated with same context.");-
582 return false;-
583 }-
584 d->glfuncs->glAttachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id());-
585 d->linked = false;-
586 d->shaders.append(shader);-
587 connect(shader, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "843""849"), this, qFlagLocation("1""shaderDestroyed()" "\0" __FILE__ ":" "843""849"));-
588 return true;-
589 } else {-
590 return false;-
591 }-
592}-
593bool QOpenGLShaderProgram::addShaderFromSourceCode(QOpenGLShader::ShaderType type, const char *source)-
594{-
595 QOpenGLShaderProgramPrivate * const d = d_func();-
596 if (!init())-
597 return false;-
598 QOpenGLShader *shader = new QOpenGLShader(type, this);-
599 if (!shader->compileSourceCode(source)) {-
600 d->log = shader->log();-
601 delete shader;-
602 return false;-
603 }-
604 d->anonShaders.append(shader);-
605 return addShader(shader);-
606}-
607bool QOpenGLShaderProgram::addShaderFromSourceCode(QOpenGLShader::ShaderType type, const QByteArray& source)-
608{-
609 return addShaderFromSourceCode(type, source.constData());-
610}-
611bool QOpenGLShaderProgram::addShaderFromSourceCode(QOpenGLShader::ShaderType type, const QString& source)-
612{-
613 return addShaderFromSourceCode(type, source.toLatin1().constData());-
614}-
615bool QOpenGLShaderProgram::addShaderFromSourceFile-
616 (QOpenGLShader::ShaderType type, const QString& fileName)-
617{-
618 QOpenGLShaderProgramPrivate * const d = d_func();-
619 if (!init())-
620 return false;-
621 QOpenGLShader *shader = new QOpenGLShader(type, this);-
622 if (!shader->compileSourceFile(fileName)) {-
623 d->log = shader->log();-
624 delete shader;-
625 return false;-
626 }-
627 d->anonShaders.append(shader);-
628 return addShader(shader);-
629}-
630void QOpenGLShaderProgram::removeShader(QOpenGLShader *shader)-
631{-
632 QOpenGLShaderProgramPrivate * const d = d_func();-
633 if (d->programGuard && d->programGuard->id()-
634 && shader && shader->d_func()->shaderGuard)-
635 {-
636 d->glfuncs->glDetachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id());-
637 }-
638 d->linked = false;-
639 if (shader) {-
640 d->shaders.removeAll(shader);-
641 d->anonShaders.removeAll(shader);-
642 disconnect(shader, qFlagLocation("2""destroyed()" "\0" __FILE__ ":" "965""971"), this, qFlagLocation("1""shaderDestroyed()" "\0" __FILE__ ":" "965""971"));-
643 }-
644}-
645-
646-
647-
648-
649-
650-
651-
652QList<QOpenGLShader *> QOpenGLShaderProgram::shaders() const-
653{-
654 const QOpenGLShaderProgramPrivate * const d = d_func();-
655 return d->shaders;-
656}-
657void QOpenGLShaderProgram::removeAllShaders()-
658{-
659 QOpenGLShaderProgramPrivate * const d = d_func();-
660 d->removingShaders = true;-
661 for (QForeachContainer<typename QtPrivate::remove_reference<decltypeQOpenGLShader *shader : qAsConst(d->shaders)>::type> _container_((d->shaders)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QOpenGLShader *shader = *_container_.i; _container_.control; _container_.control = 0))) {-
662 if (d->programGuard
d->programGuardDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->programGuard->id()
d->programGuard->id()Description
TRUEnever evaluated
FALSEnever evaluated
0
663 && shader
shaderDescription
TRUEnever evaluated
FALSEnever evaluated
&& shader->d_func()->shaderGuard
shader->d_func()->shaderGuardDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
664 {-
665 d->glfuncs->glDetachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id());-
666 }
never executed: end of block
0
667 }
never executed: end of block
0
668-
669 for (QForeachContainer<typename QtPrivate::remove_reference<decltypeqDeleteAll(d->anonShaders)>::type> _container_((d->anonShaders)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QOpenGLShader *shader = *_container_.i; _container_.control; _container_.control = 0) {-
delete shader;
});
670 d->shaders.clear();-
671 d->anonShaders.clear();-
672 d->linked = false;-
673 d->removingShaders = false;-
674}
never executed: end of block
0
675bool QOpenGLShaderProgram::link()-
676{-
677 QOpenGLShaderProgramPrivate * const d = d_func();-
678 GLuint program = d->programGuard
d->programGuardDescription
TRUEnever evaluated
FALSEnever evaluated
? d->programGuard->id() : 0;
0
679 if (!program
!programDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
680 return
never executed: return false;
false;
never executed: return false;
0
681-
682 GLint value;-
683 if (d->shaders.isEmpty()
d->shaders.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
684-
685-
686-
687-
688 value = 0;-
689 d->glfuncs->glGetProgramiv(program, 0x8B82, &value);-
690 d->linked = (value != 0);-
691 if (d->linked
d->linkedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
692 return
never executed: return true;
true;
never executed: return true;
0
693 }
never executed: end of block
0
694-
695 d->glfuncs->glLinkProgram(program);-
696 value = 0;-
697 d->glfuncs->glGetProgramiv(program, 0x8B82, &value);-
698 d->linked = (value != 0);-
699 value = 0;-
700 d->glfuncs->glGetProgramiv(program, 0x8B84, &value);-
701 d->log = QString();-
702 if (value > 1
value > 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
703 char *logbuf = new char [value];-
704 GLint len;-
705 d->glfuncs->glGetProgramInfoLog(program, value, &len, logbuf);-
706 d->log = QString::fromLatin1(logbuf);-
707 if (!d->linked
!d->linkedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
708 QString name = objectName();-
709 if (name.isEmpty()
name.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
710 QMessageLogger(__FILE__, 10591063, __PRETTY_FUNCTION__).warning() << ("QOpenGLShader::link:" << %ls", static_cast<const wchar_t*>(static_cast<const void*>(QString(d->log;).utf16())));
never executed: QMessageLogger(__FILE__, 1063, __PRETTY_FUNCTION__).warning("QOpenGLShader::link: %ls", static_cast<const wchar_t*>(static_cast<const void*>(QString(d->log).utf16())));
0
711 else-
712 QMessageLogger(__FILE__, 10611065, __PRETTY_FUNCTION__).warning() << ("QOpenGLShader::link[" << name << "%ls]:" << %ls", static_cast<const wchar_t*>(static_cast<const void*>(QString(name).utf16())), static_cast<const wchar_t*>(static_cast<const void*>(QString(d->log;).utf16())));
never executed: QMessageLogger(__FILE__, 1065, __PRETTY_FUNCTION__).warning("QOpenGLShader::link[%ls]: %ls", static_cast<const wchar_t*>(static_cast<const void*>(QString(name).utf16())), static_cast<const wchar_t*>(static_cast<const void*>(QString(d->log).utf16())));
0
713 }-
714 delete [] logbuf;-
715 }
never executed: end of block
0
716 return
never executed: return d->linked;
d->linked;
never executed: return d->linked;
0
717}-
718-
719-
720-
721-
722-
723-
724bool QOpenGLShaderProgram::isLinked() const-
725{-
726 const QOpenGLShaderProgramPrivate * const d = d_func();-
727 return d->linked;-
728}-
729-
730-
731-
732-
733-
734-
735-
736QString QOpenGLShaderProgram::log() const-
737{-
738 const QOpenGLShaderProgramPrivate * const d = d_func();-
739 return d->log;-
740}-
741bool QOpenGLShaderProgram::bind()-
742{-
743 QOpenGLShaderProgramPrivate * const d = d_func();-
744 GLuint program = d->programGuard ? d->programGuard->id() : 0;-
745 if (!program)-
746 return false;-
747 if (!d->linked && !link())-
748 return false;-
749-
750 if (d->programGuard->group() != QOpenGLContextGroup::currentContextGroup()) {-
751 QMessageLogger(__FILE__, 11111115, __PRETTY_FUNCTION__).warning("QOpenGLShaderProgram::bind: program is not valid in the current context.");-
752 return false;-
753 }-
754-
755 d->glfuncs->glUseProgram(program);-
756 return true;-
757}-
758-
759-
760-
761-
762-
763-
764-
765void QOpenGLShaderProgram::release()-
766{-
767 QOpenGLShaderProgramPrivate * const d = d_func();-
768-
769 if (d->programGuard && d->programGuard->group() != QOpenGLContextGroup::currentContextGroup())-
770 QMessageLogger(__FILE__, 11301134, __PRETTY_FUNCTION__).warning("QOpenGLShaderProgram::release: program is not valid in the current context.");-
771-
772 d->glfuncs->glUseProgram(0);-
773}-
774-
775-
776-
777-
778-
779-
780GLuint QOpenGLShaderProgram::programId() const-
781{-
782 const QOpenGLShaderProgramPrivate * const d = d_func();-
783 GLuint id = d->programGuard ? d->programGuard->id() : 0;-
784 if (id)-
785 return id;-
786-
787-
788-
789-
790 if (!const_cast<QOpenGLShaderProgram *>(this)->init())-
791 return 0;-
792 return d->programGuard ? d->programGuard->id() : 0;-
793}-
794void QOpenGLShaderProgram::bindAttributeLocation(const char *name, int location)-
795{-
796 QOpenGLShaderProgramPrivate * const d = d_func();-
797 if (!init() || !d->programGuard || !d->programGuard->id())-
798 return;-
799 d->glfuncs->glBindAttribLocation(d->programGuard->id(), location, name);-
800 d->linked = false;-
801}-
802void QOpenGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location)-
803{-
804 bindAttributeLocation(name.constData(), location);-
805}-
806void QOpenGLShaderProgram::bindAttributeLocation(const QString& name, int location)-
807{-
808 bindAttributeLocation(name.toLatin1().constData(), location);-
809}-
810int QOpenGLShaderProgram::attributeLocation(const char *name) const-
811{-
812 const QOpenGLShaderProgramPrivate * const d = d_func();-
813 if (d->linked && d->programGuard && d->programGuard->id()) {-
814 return d->glfuncs->glGetAttribLocation(d->programGuard->id(), name);-
815 } else {-
816 QMessageLogger(__FILE__, 12241228, __PRETTY_FUNCTION__).warning() << "QOpenGLShaderProgram::attributeLocation(" << name-
817 << "): shader program is not linked";-
818 return -1;-
819 }-
820}-
821int QOpenGLShaderProgram::attributeLocation(const QByteArray& name) const-
822{-
823 return attributeLocation(name.constData());-
824}-
825int QOpenGLShaderProgram::attributeLocation(const QString& name) const-
826{-
827 return attributeLocation(name.toLatin1().constData());-
828}-
829-
830-
831-
832-
833-
834-
835void QOpenGLShaderProgram::setAttributeValue(int location, GLfloat value)-
836{-
837 QOpenGLShaderProgramPrivate * const d = d_func();-
838 if (location != -1)-
839 d->glfuncs->glVertexAttrib1fv(location, &value);-
840}-
841void QOpenGLShaderProgram::setAttributeValue(const char *name, GLfloat value)-
842{-
843 setAttributeValue(attributeLocation(name), value);-
844}-
845-
846-
847-
848-
849-
850-
851-
852void QOpenGLShaderProgram::setAttributeValue(int location, GLfloat x, GLfloat y)-
853{-
854 QOpenGLShaderProgramPrivate * const d = d_func();-
855 if (location != -1) {-
856 GLfloat values[2] = {x, y};-
857 d->glfuncs->glVertexAttrib2fv(location, values);-
858 }-
859}-
860void QOpenGLShaderProgram::setAttributeValue(const char *name, GLfloat x, GLfloat y)-
861{-
862 setAttributeValue(attributeLocation(name), x, y);-
863}-
864-
865-
866-
867-
868-
869-
870-
871void QOpenGLShaderProgram::setAttributeValue-
872 (int location, GLfloat x, GLfloat y, GLfloat z)-
873{-
874 QOpenGLShaderProgramPrivate * const d = d_func();-
875 (void)d;;-
876 if (location != -1) {-
877 GLfloat values[3] = {x, y, z};-
878 d->glfuncs->glVertexAttrib3fv(location, values);-
879 }-
880}-
881void QOpenGLShaderProgram::setAttributeValue-
882 (const char *name, GLfloat x, GLfloat y, GLfloat z)-
883{-
884 setAttributeValue(attributeLocation(name), x, y, z);-
885}-
886-
887-
888-
889-
890-
891-
892-
893void QOpenGLShaderProgram::setAttributeValue-
894 (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)-
895{-
896 QOpenGLShaderProgramPrivate * const d = d_func();-
897 if (location != -1) {-
898 GLfloat values[4] = {x, y, z, w};-
899 d->glfuncs->glVertexAttrib4fv(location, values);-
900 }-
901}-
902void QOpenGLShaderProgram::setAttributeValue-
903 (const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)-
904{-
905 setAttributeValue(attributeLocation(name), x, y, z, w);-
906}-
907-
908-
909-
910-
911-
912-
913void QOpenGLShaderProgram::setAttributeValue(int location, const QVector2D& value)-
914{-
915 QOpenGLShaderProgramPrivate * const d = d_func();-
916 if (location != -1)-
917 d->glfuncs->glVertexAttrib2fv(location, reinterpret_cast<const GLfloat *>(&value));-
918}-
919void QOpenGLShaderProgram::setAttributeValue(const char *name, const QVector2D& value)-
920{-
921 setAttributeValue(attributeLocation(name), value);-
922}-
923-
924-
925-
926-
927-
928-
929void QOpenGLShaderProgram::setAttributeValue(int location, const QVector3D& value)-
930{-
931 QOpenGLShaderProgramPrivate * const d = d_func();-
932 (void)d;;-
933 if (location != -1)-
934 d->glfuncs->glVertexAttrib3fv(location, reinterpret_cast<const GLfloat *>(&value));-
935}-
936void QOpenGLShaderProgram::setAttributeValue(const char *name, const QVector3D& value)-
937{-
938 setAttributeValue(attributeLocation(name), value);-
939}-
940-
941-
942-
943-
944-
945-
946void QOpenGLShaderProgram::setAttributeValue(int location, const QVector4D& value)-
947{-
948 QOpenGLShaderProgramPrivate * const d = d_func();-
949 (void)d;;-
950 if (location != -1)-
951 d->glfuncs->glVertexAttrib4fv(location, reinterpret_cast<const GLfloat *>(&value));-
952}-
953void QOpenGLShaderProgram::setAttributeValue(const char *name, const QVector4D& value)-
954{-
955 setAttributeValue(attributeLocation(name), value);-
956}-
957-
958-
959-
960-
961-
962-
963void QOpenGLShaderProgram::setAttributeValue(int location, const QColor& value)-
964{-
965 QOpenGLShaderProgramPrivate * const d = d_func();-
966 (void)d;;-
967 if (location != -1) {-
968 GLfloat values[4] = {GLfloat(value.redF()), GLfloat(value.greenF()),-
969 GLfloat(value.blueF()), GLfloat(value.alphaF())};-
970 d->glfuncs->glVertexAttrib4fv(location, values);-
971 }-
972}-
973void QOpenGLShaderProgram::setAttributeValue(const char *name, const QColor& value)-
974{-
975 setAttributeValue(attributeLocation(name), value);-
976}-
977void QOpenGLShaderProgram::setAttributeValue-
978 (int location, const GLfloat *values, int columns, int rows)-
979{-
980 QOpenGLShaderProgramPrivate * const d = d_func();-
981 (void)d;;-
982 if (rows < 1 || rows > 4) {-
983 QMessageLogger(__FILE__, 14881492, __PRETTY_FUNCTION__).warning() << "QOpenGLShaderProgram::setAttributeValue: rows" << rows << "not supported";-
984 return;-
985 }-
986 if (location != -1) {-
987 while (columns-- > 0) {-
988 if (rows == 1)-
989 d->glfuncs->glVertexAttrib1fv(location, values);-
990 else if (rows == 2)-
991 d->glfuncs->glVertexAttrib2fv(location, values);-
992 else if (rows == 3)-
993 d->glfuncs->glVertexAttrib3fv(location, values);-
994 else-
995 d->glfuncs->glVertexAttrib4fv(location, values);-
996 values += rows;-
997 ++location;-
998 }-
999 }-
1000}-
1001void QOpenGLShaderProgram::setAttributeValue-
1002 (const char *name, const GLfloat *values, int columns, int rows)-
1003{-
1004 setAttributeValue(attributeLocation(name), values, columns, rows);-
1005}-
1006void QOpenGLShaderProgram::setAttributeArray-
1007 (int location, const GLfloat *values, int tupleSize, int stride)-
1008{-
1009 QOpenGLShaderProgramPrivate * const d = d_func();-
1010 (void)d;;-
1011 if (location != -1) {-
1012 d->glfuncs->glVertexAttribPointer(location, tupleSize, 0x1406, 0,-
1013 stride, values);-
1014 }-
1015}-
1016void QOpenGLShaderProgram::setAttributeArray-
1017 (int location, const QVector2D *values, int stride)-
1018{-
1019 QOpenGLShaderProgramPrivate * const d = d_func();-
1020 (void)d;;-
1021 if (location != -1) {-
1022 d->glfuncs->glVertexAttribPointer(location, 2, 0x1406, 0,-
1023 stride, values);-
1024 }-
1025}-
1026void QOpenGLShaderProgram::setAttributeArray-
1027 (int location, const QVector3D *values, int stride)-
1028{-
1029 QOpenGLShaderProgramPrivate * const d = d_func();-
1030 (void)d;;-
1031 if (location != -1) {-
1032 d->glfuncs->glVertexAttribPointer(location, 3, 0x1406, 0,-
1033 stride, values);-
1034 }-
1035}-
1036void QOpenGLShaderProgram::setAttributeArray-
1037 (int location, const QVector4D *values, int stride)-
1038{-
1039 QOpenGLShaderProgramPrivate * const d = d_func();-
1040 (void)d;;-
1041 if (location != -1) {-
1042 d->glfuncs->glVertexAttribPointer(location, 4, 0x1406, 0,-
1043 stride, values);-
1044 }-
1045}-
1046void QOpenGLShaderProgram::setAttributeArray-
1047 (int location, GLenum type, const void *values, int tupleSize, int stride)-
1048{-
1049 QOpenGLShaderProgramPrivate * const d = d_func();-
1050 (void)d;;-
1051 if (location != -1) {-
1052 d->glfuncs->glVertexAttribPointer(location, tupleSize, type, 1,-
1053 stride, values);-
1054 }-
1055}-
1056void QOpenGLShaderProgram::setAttributeArray-
1057 (const char *name, const GLfloat *values, int tupleSize, int stride)-
1058{-
1059 setAttributeArray(attributeLocation(name), values, tupleSize, stride);-
1060}-
1061void QOpenGLShaderProgram::setAttributeArray-
1062 (const char *name, const QVector2D *values, int stride)-
1063{-
1064 setAttributeArray(attributeLocation(name), values, stride);-
1065}-
1066void QOpenGLShaderProgram::setAttributeArray-
1067 (const char *name, const QVector3D *values, int stride)-
1068{-
1069 setAttributeArray(attributeLocation(name), values, stride);-
1070}-
1071void QOpenGLShaderProgram::setAttributeArray-
1072 (const char *name, const QVector4D *values, int stride)-
1073{-
1074 setAttributeArray(attributeLocation(name), values, stride);-
1075}-
1076void QOpenGLShaderProgram::setAttributeArray-
1077 (const char *name, GLenum type, const void *values, int tupleSize, int stride)-
1078{-
1079 setAttributeArray(attributeLocation(name), type, values, tupleSize, stride);-
1080}-
1081void QOpenGLShaderProgram::setAttributeBuffer-
1082 (int location, GLenum type, int offset, int tupleSize, int stride)-
1083{-
1084 QOpenGLShaderProgramPrivate * const d = d_func();-
1085 (void)d;;-
1086 if (location != -1) {-
1087 d->glfuncs->glVertexAttribPointer(location, tupleSize, type, 1, stride,-
1088 reinterpret_cast<const void *>(qintptr(offset)));-
1089 }-
1090}-
1091void QOpenGLShaderProgram::setAttributeBuffer-
1092 (const char *name, GLenum type, int offset, int tupleSize, int stride)-
1093{-
1094 setAttributeBuffer(attributeLocation(name), type, offset, tupleSize, stride);-
1095}-
1096void QOpenGLShaderProgram::enableAttributeArray(int location)-
1097{-
1098 QOpenGLShaderProgramPrivate * const d = d_func();-
1099 (void)d;;-
1100 if (location != -1)-
1101 d->glfuncs->glEnableVertexAttribArray(location);-
1102}-
1103void QOpenGLShaderProgram::enableAttributeArray(const char *name)-
1104{-
1105 enableAttributeArray(attributeLocation(name));-
1106}-
1107void QOpenGLShaderProgram::disableAttributeArray(int location)-
1108{-
1109 QOpenGLShaderProgramPrivate * const d = d_func();-
1110 (void)d;;-
1111 if (location != -1)-
1112 d->glfuncs->glDisableVertexAttribArray(location);-
1113}-
1114void QOpenGLShaderProgram::disableAttributeArray(const char *name)-
1115{-
1116 disableAttributeArray(attributeLocation(name));-
1117}-
1118int QOpenGLShaderProgram::uniformLocation(const char *name) const-
1119{-
1120 const QOpenGLShaderProgramPrivate * const d = d_func();-
1121 (void)d;;-
1122 if (d->linked && d->programGuard && d->programGuard->id()) {-
1123 return d->glfuncs->glGetUniformLocation(d->programGuard->id(), name);-
1124 } else {-
1125 QMessageLogger(__FILE__, 19001904, __PRETTY_FUNCTION__).warning() << "QOpenGLShaderProgram::uniformLocation(" << name-
1126 << "): shader program is not linked";-
1127 return -1;-
1128 }-
1129}-
1130int QOpenGLShaderProgram::uniformLocation(const QByteArray& name) const-
1131{-
1132 return uniformLocation(name.constData());-
1133}-
1134int QOpenGLShaderProgram::uniformLocation(const QString& name) const-
1135{-
1136 return uniformLocation(name.toLatin1().constData());-
1137}-
1138-
1139-
1140-
1141-
1142-
1143-
1144void QOpenGLShaderProgram::setUniformValue(int location, GLfloat value)-
1145{-
1146 QOpenGLShaderProgramPrivate * const d = d_func();-
1147 (void)d;;-
1148 if (location != -1)-
1149 d->glfuncs->glUniform1fv(location, 1, &value);-
1150}-
1151void QOpenGLShaderProgram::setUniformValue(const char *name, GLfloat value)-
1152{-
1153 setUniformValue(uniformLocation(name), value);-
1154}-
1155-
1156-
1157-
1158-
1159-
1160-
1161void QOpenGLShaderProgram::setUniformValue(int location, GLint value)-
1162{-
1163 QOpenGLShaderProgramPrivate * const d = d_func();-
1164 (void)d;;-
1165 if (location != -1)-
1166 d->glfuncs->glUniform1i(location, value);-
1167}-
1168void QOpenGLShaderProgram::setUniformValue(const char *name, GLint value)-
1169{-
1170 setUniformValue(uniformLocation(name), value);-
1171}-
1172void QOpenGLShaderProgram::setUniformValue(int location, GLuint value)-
1173{-
1174 QOpenGLShaderProgramPrivate * const d = d_func();-
1175 (void)d;;-
1176 if (location != -1)-
1177 d->glfuncs->glUniform1i(location, value);-
1178}-
1179void QOpenGLShaderProgram::setUniformValue(const char *name, GLuint value)-
1180{-
1181 setUniformValue(uniformLocation(name), value);-
1182}-
1183-
1184-
1185-
1186-
1187-
1188-
1189-
1190void QOpenGLShaderProgram::setUniformValue(int location, GLfloat x, GLfloat y)-
1191{-
1192 QOpenGLShaderProgramPrivate * const d = d_func();-
1193 (void)d;;-
1194 if (location != -1) {-
1195 GLfloat values[2] = {x, y};-
1196 d->glfuncs->glUniform2fv(location, 1, values);-
1197 }-
1198}-
1199void QOpenGLShaderProgram::setUniformValue(const char *name, GLfloat x, GLfloat y)-
1200{-
1201 setUniformValue(uniformLocation(name), x, y);-
1202}-
1203-
1204-
1205-
1206-
1207-
1208-
1209-
1210void QOpenGLShaderProgram::setUniformValue-
1211 (int location, GLfloat x, GLfloat y, GLfloat z)-
1212{-
1213 QOpenGLShaderProgramPrivate * const d = d_func();-
1214 (void)d;;-
1215 if (location != -1) {-
1216 GLfloat values[3] = {x, y, z};-
1217 d->glfuncs->glUniform3fv(location, 1, values);-
1218 }-
1219}-
1220void QOpenGLShaderProgram::setUniformValue-
1221 (const char *name, GLfloat x, GLfloat y, GLfloat z)-
1222{-
1223 setUniformValue(uniformLocation(name), x, y, z);-
1224}-
1225-
1226-
1227-
1228-
1229-
1230-
1231-
1232void QOpenGLShaderProgram::setUniformValue-
1233 (int location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)-
1234{-
1235 QOpenGLShaderProgramPrivate * const d = d_func();-
1236 (void)d;;-
1237 if (location != -1) {-
1238 GLfloat values[4] = {x, y, z, w};-
1239 d->glfuncs->glUniform4fv(location, 1, values);-
1240 }-
1241}-
1242void QOpenGLShaderProgram::setUniformValue-
1243 (const char *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)-
1244{-
1245 setUniformValue(uniformLocation(name), x, y, z, w);-
1246}-
1247-
1248-
1249-
1250-
1251-
1252-
1253void QOpenGLShaderProgram::setUniformValue(int location, const QVector2D& value)-
1254{-
1255 QOpenGLShaderProgramPrivate * const d = d_func();-
1256 (void)d;;-
1257 if (location != -1)-
1258 d->glfuncs->glUniform2fv(location, 1, reinterpret_cast<const GLfloat *>(&value));-
1259}-
1260void QOpenGLShaderProgram::setUniformValue(const char *name, const QVector2D& value)-
1261{-
1262 setUniformValue(uniformLocation(name), value);-
1263}-
1264-
1265-
1266-
1267-
1268-
1269-
1270void QOpenGLShaderProgram::setUniformValue(int location, const QVector3D& value)-
1271{-
1272 QOpenGLShaderProgramPrivate * const d = d_func();-
1273 (void)d;;-
1274 if (location != -1)-
1275 d->glfuncs->glUniform3fv(location, 1, reinterpret_cast<const GLfloat *>(&value));-
1276}-
1277void QOpenGLShaderProgram::setUniformValue(const char *name, const QVector3D& value)-
1278{-
1279 setUniformValue(uniformLocation(name), value);-
1280}-
1281-
1282-
1283-
1284-
1285-
1286-
1287void QOpenGLShaderProgram::setUniformValue(int location, const QVector4D& value)-
1288{-
1289 QOpenGLShaderProgramPrivate * const d = d_func();-
1290 (void)d;;-
1291 if (location != -1)-
1292 d->glfuncs->glUniform4fv(location, 1, reinterpret_cast<const GLfloat *>(&value));-
1293}-
1294void QOpenGLShaderProgram::setUniformValue(const char *name, const QVector4D& value)-
1295{-
1296 setUniformValue(uniformLocation(name), value);-
1297}-
1298-
1299-
1300-
1301-
1302-
1303-
1304-
1305void QOpenGLShaderProgram::setUniformValue(int location, const QColor& color)-
1306{-
1307 QOpenGLShaderProgramPrivate * const d = d_func();-
1308 (void)d;;-
1309 if (location != -1) {-
1310 GLfloat values[4] = {GLfloat(color.redF()), GLfloat(color.greenF()),-
1311 GLfloat(color.blueF()), GLfloat(color.alphaF())};-
1312 d->glfuncs->glUniform4fv(location, 1, values);-
1313 }-
1314}-
1315void QOpenGLShaderProgram::setUniformValue(const char *name, const QColor& color)-
1316{-
1317 setUniformValue(uniformLocation(name), color);-
1318}-
1319-
1320-
1321-
1322-
1323-
1324-
1325-
1326void QOpenGLShaderProgram::setUniformValue(int location, const QPoint& point)-
1327{-
1328 QOpenGLShaderProgramPrivate * const d = d_func();-
1329 (void)d;;-
1330 if (location != -1) {-
1331 GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())};-
1332 d->glfuncs->glUniform2fv(location, 1, values);-
1333 }-
1334}-
1335void QOpenGLShaderProgram::setUniformValue(const char *name, const QPoint& point)-
1336{-
1337 setUniformValue(uniformLocation(name), point);-
1338}-
1339-
1340-
1341-
1342-
1343-
1344-
1345-
1346void QOpenGLShaderProgram::setUniformValue(int location, const QPointF& point)-
1347{-
1348 QOpenGLShaderProgramPrivate * const d = d_func();-
1349 (void)d;;-
1350 if (location != -1) {-
1351 GLfloat values[4] = {GLfloat(point.x()), GLfloat(point.y())};-
1352 d->glfuncs->glUniform2fv(location, 1, values);-
1353 }-
1354}-
1355void QOpenGLShaderProgram::setUniformValue(const char *name, const QPointF& point)-
1356{-
1357 setUniformValue(uniformLocation(name), point);-
1358}-
1359-
1360-
1361-
1362-
1363-
1364-
1365-
1366void QOpenGLShaderProgram::setUniformValue(int location, const QSize& size)-
1367{-
1368 QOpenGLShaderProgramPrivate * const d = d_func();-
1369 (void)d;;-
1370 if (location != -1) {-
1371 GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())};-
1372 d->glfuncs->glUniform2fv(location, 1, values);-
1373 }-
1374}-
1375void QOpenGLShaderProgram::setUniformValue(const char *name, const QSize& size)-
1376{-
1377 setUniformValue(uniformLocation(name), size);-
1378}-
1379-
1380-
1381-
1382-
1383-
1384-
1385-
1386void QOpenGLShaderProgram::setUniformValue(int location, const QSizeF& size)-
1387{-
1388 QOpenGLShaderProgramPrivate * const d = d_func();-
1389 (void)d;;-
1390 if (location != -1) {-
1391 GLfloat values[4] = {GLfloat(size.width()), GLfloat(size.height())};-
1392 d->glfuncs->glUniform2fv(location, 1, values);-
1393 }-
1394}-
1395void QOpenGLShaderProgram::setUniformValue(const char *name, const QSizeF& size)-
1396{-
1397 setUniformValue(uniformLocation(name), size);-
1398}-
1399-
1400-
1401-
1402-
1403-
1404-
1405-
1406void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix2x2& value)-
1407{-
1408 QOpenGLShaderProgramPrivate * const d = d_func();-
1409 (void)d;;-
1410 d->glfuncs->glUniformMatrix2fv(location, 1, 0, value.constData());-
1411}-
1412void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix2x2& value)-
1413{-
1414 setUniformValue(uniformLocation(name), value);-
1415}-
1416void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix2x3& value)-
1417{-
1418 QOpenGLShaderProgramPrivate * const d = d_func();-
1419 (void)d;;-
1420 d->glfuncs->glUniform3fv(location, 2, value.constData());-
1421}-
1422void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix2x3& value)-
1423{-
1424 setUniformValue(uniformLocation(name), value);-
1425}-
1426void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix2x4& value)-
1427{-
1428 QOpenGLShaderProgramPrivate * const d = d_func();-
1429 (void)d;;-
1430 d->glfuncs->glUniform4fv(location, 2, value.constData());-
1431}-
1432void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix2x4& value)-
1433{-
1434 setUniformValue(uniformLocation(name), value);-
1435}-
1436void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix3x2& value)-
1437{-
1438 QOpenGLShaderProgramPrivate * const d = d_func();-
1439 (void)d;;-
1440 d->glfuncs->glUniform2fv(location, 3, value.constData());-
1441}-
1442void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix3x2& value)-
1443{-
1444 setUniformValue(uniformLocation(name), value);-
1445}-
1446-
1447-
1448-
1449-
1450-
1451-
1452-
1453void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix3x3& value)-
1454{-
1455 QOpenGLShaderProgramPrivate * const d = d_func();-
1456 (void)d;;-
1457 d->glfuncs->glUniformMatrix3fv(location, 1, 0, value.constData());-
1458}-
1459void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix3x3& value)-
1460{-
1461 setUniformValue(uniformLocation(name), value);-
1462}-
1463void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix3x4& value)-
1464{-
1465 QOpenGLShaderProgramPrivate * const d = d_func();-
1466 (void)d;;-
1467 d->glfuncs->glUniform4fv(location, 3, value.constData());-
1468}-
1469void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix3x4& value)-
1470{-
1471 setUniformValue(uniformLocation(name), value);-
1472}-
1473void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix4x2& value)-
1474{-
1475 QOpenGLShaderProgramPrivate * const d = d_func();-
1476 (void)d;;-
1477 d->glfuncs->glUniform2fv(location, 4, value.constData());-
1478}-
1479void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix4x2& value)-
1480{-
1481 setUniformValue(uniformLocation(name), value);-
1482}-
1483void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix4x3& value)-
1484{-
1485 QOpenGLShaderProgramPrivate * const d = d_func();-
1486 (void)d;;-
1487 d->glfuncs->glUniform3fv(location, 4, value.constData());-
1488}-
1489void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix4x3& value)-
1490{-
1491 setUniformValue(uniformLocation(name), value);-
1492}-
1493-
1494-
1495-
1496-
1497-
1498-
1499-
1500void QOpenGLShaderProgram::setUniformValue(int location, const QMatrix4x4& value)-
1501{-
1502 QOpenGLShaderProgramPrivate * const d = d_func();-
1503 (void)d;;-
1504 d->glfuncs->glUniformMatrix4fv(location, 1, 0, value.constData());-
1505}-
1506void QOpenGLShaderProgram::setUniformValue(const char *name, const QMatrix4x4& value)-
1507{-
1508 setUniformValue(uniformLocation(name), value);-
1509}-
1510void QOpenGLShaderProgram::setUniformValue(int location, const GLfloat value[2][2])-
1511{-
1512 QOpenGLShaderProgramPrivate * const d = d_func();-
1513 (void)d;;-
1514 if (location != -1)-
1515 d->glfuncs->glUniformMatrix2fv(location, 1, 0, value[0]);-
1516}-
1517void QOpenGLShaderProgram::setUniformValue(int location, const GLfloat value[3][3])-
1518{-
1519 QOpenGLShaderProgramPrivate * const d = d_func();-
1520 (void)d;;-
1521 if (location != -1)-
1522 d->glfuncs->glUniformMatrix3fv(location, 1, 0, value[0]);-
1523}-
1524void QOpenGLShaderProgram::setUniformValue(int location, const GLfloat value[4][4])-
1525{-
1526 QOpenGLShaderProgramPrivate * const d = d_func();-
1527 (void)d;;-
1528 if (location != -1)-
1529 d->glfuncs->glUniformMatrix4fv(location, 1, 0, value[0]);-
1530}-
1531void QOpenGLShaderProgram::setUniformValue(const char *name, const GLfloat value[2][2])-
1532{-
1533 setUniformValue(uniformLocation(name), value);-
1534}-
1535void QOpenGLShaderProgram::setUniformValue(const char *name, const GLfloat value[3][3])-
1536{-
1537 setUniformValue(uniformLocation(name), value);-
1538}-
1539void QOpenGLShaderProgram::setUniformValue(const char *name, const GLfloat value[4][4])-
1540{-
1541 setUniformValue(uniformLocation(name), value);-
1542}-
1543void QOpenGLShaderProgram::setUniformValue(int location, const QTransform& value)-
1544{-
1545 QOpenGLShaderProgramPrivate * const d = d_func();-
1546 (void)d;;-
1547 if (location != -1) {-
1548 GLfloat mat[3][3] = {-
1549 {GLfloat(value.m11()), GLfloat(value.m12()), GLfloat(value.m13())},-
1550 {GLfloat(value.m21()), GLfloat(value.m22()), GLfloat(value.m23())},-
1551 {GLfloat(value.m31()), GLfloat(value.m32()), GLfloat(value.m33())}-
1552 };-
1553 d->glfuncs->glUniformMatrix3fv(location, 1, 0, mat[0]);-
1554 }-
1555}-
1556void QOpenGLShaderProgram::setUniformValue-
1557 (const char *name, const QTransform& value)-
1558{-
1559 setUniformValue(uniformLocation(name), value);-
1560}-
1561-
1562-
1563-
1564-
1565-
1566-
1567-
1568void QOpenGLShaderProgram::setUniformValueArray(int location, const GLint *values, int count)-
1569{-
1570 QOpenGLShaderProgramPrivate * const d = d_func();-
1571 (void)d;;-
1572 if (location != -1)-
1573 d->glfuncs->glUniform1iv(location, count, values);-
1574}-
1575void QOpenGLShaderProgram::setUniformValueArray-
1576 (const char *name, const GLint *values, int count)-
1577{-
1578 setUniformValueArray(uniformLocation(name), values, count);-
1579}-
1580void QOpenGLShaderProgram::setUniformValueArray(int location, const GLuint *values, int count)-
1581{-
1582 QOpenGLShaderProgramPrivate * const d = d_func();-
1583 (void)d;;-
1584 if (location != -1)-
1585 d->glfuncs->glUniform1iv(location, count, reinterpret_cast<const GLint *>(values));-
1586}-
1587void QOpenGLShaderProgram::setUniformValueArray-
1588 (const char *name, const GLuint *values, int count)-
1589{-
1590 setUniformValueArray(uniformLocation(name), values, count);-
1591}-
1592void QOpenGLShaderProgram::setUniformValueArray(int location, const GLfloat *values, int count, int tupleSize)-
1593{-
1594 QOpenGLShaderProgramPrivate * const d = d_func();-
1595 (void)d;;-
1596 if (location != -1) {-
1597 if (tupleSize == 1)-
1598 d->glfuncs->glUniform1fv(location, count, values);-
1599 else if (tupleSize == 2)-
1600 d->glfuncs->glUniform2fv(location, count, values);-
1601 else if (tupleSize == 3)-
1602 d->glfuncs->glUniform3fv(location, count, values);-
1603 else if (tupleSize == 4)-
1604 d->glfuncs->glUniform4fv(location, count, values);-
1605 else-
1606 QMessageLogger(__FILE__, 28282832, __PRETTY_FUNCTION__).warning() << "QOpenGLShaderProgram::setUniformValue: size" << tupleSize << "not supported";-
1607 }-
1608}-
1609void QOpenGLShaderProgram::setUniformValueArray-
1610 (const char *name, const GLfloat *values, int count, int tupleSize)-
1611{-
1612 setUniformValueArray(uniformLocation(name), values, count, tupleSize);-
1613}-
1614-
1615-
1616-
1617-
1618-
1619-
1620-
1621void QOpenGLShaderProgram::setUniformValueArray(int location, const QVector2D *values, int count)-
1622{-
1623 QOpenGLShaderProgramPrivate * const d = d_func();-
1624 (void)d;;-
1625 if (location != -1)-
1626 d->glfuncs->glUniform2fv(location, count, reinterpret_cast<const GLfloat *>(values));-
1627}-
1628void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QVector2D *values, int count)-
1629{-
1630 setUniformValueArray(uniformLocation(name), values, count);-
1631}-
1632-
1633-
1634-
1635-
1636-
1637-
1638-
1639void QOpenGLShaderProgram::setUniformValueArray(int location, const QVector3D *values, int count)-
1640{-
1641 QOpenGLShaderProgramPrivate * const d = d_func();-
1642 (void)d;;-
1643 if (location != -1)-
1644 d->glfuncs->glUniform3fv(location, count, reinterpret_cast<const GLfloat *>(values));-
1645}-
1646void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QVector3D *values, int count)-
1647{-
1648 setUniformValueArray(uniformLocation(name), values, count);-
1649}-
1650-
1651-
1652-
1653-
1654-
1655-
1656-
1657void QOpenGLShaderProgram::setUniformValueArray(int location, const QVector4D *values, int count)-
1658{-
1659 QOpenGLShaderProgramPrivate * const d = d_func();-
1660 (void)d;;-
1661 if (location != -1)-
1662 d->glfuncs->glUniform4fv(location, count, reinterpret_cast<const GLfloat *>(values));-
1663}-
1664void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QVector4D *values, int count)-
1665{-
1666 setUniformValueArray(uniformLocation(name), values, count);-
1667}-
1668void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix2x2 *values, int count)-
1669{-
1670 QOpenGLShaderProgramPrivate * const d = d_func();-
1671 (void)d;;-
1672 if (location == -1 || count <= 0) return; if (sizeof(QMatrix2x2) == sizeof(GLfloat) * 2 * 2) { d->glfuncs->glUniformMatrix2fv(location, count, 0, reinterpret_cast<const GLfloat *>(values[0].constData())); } else { QVarLengthArray<GLfloat> temp(2 * 2 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (2 * 2); ++index2) { temp.data()[2 * 2 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniformMatrix2fv(location, count, 0, temp.constData()); }-
1673 ;-
1674}-
1675void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x2 *values, int count)-
1676{-
1677 setUniformValueArray(uniformLocation(name), values, count);-
1678}-
1679-
1680-
1681-
1682-
1683-
1684-
1685-
1686void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix2x3 *values, int count)-
1687{-
1688 QOpenGLShaderProgramPrivate * const d = d_func();-
1689 (void)d;;-
1690 if (location == -1 || count <= 0) return; if (sizeof(QMatrix2x3) == sizeof(GLfloat) * 2 * 3) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform3fv(location, count * 2, data); } else { QVarLengthArray<GLfloat> temp(2 * 3 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (2 * 3); ++index2) { temp.data()[2 * 3 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform3fv(location, count * 2, temp.constData()); }-
1691-
1692 ;-
1693}-
1694void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x3 *values, int count)-
1695{-
1696 setUniformValueArray(uniformLocation(name), values, count);-
1697}-
1698-
1699-
1700-
1701-
1702-
1703-
1704-
1705void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix2x4 *values, int count)-
1706{-
1707 QOpenGLShaderProgramPrivate * const d = d_func();-
1708 (void)d;;-
1709 if (location == -1 || count <= 0) return; if (sizeof(QMatrix2x4) == sizeof(GLfloat) * 2 * 4) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform4fv(location, count * 2, data); } else { QVarLengthArray<GLfloat> temp(2 * 4 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (2 * 4); ++index2) { temp.data()[2 * 4 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform4fv(location, count * 2, temp.constData()); }-
1710-
1711 ;-
1712}-
1713void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix2x4 *values, int count)-
1714{-
1715 setUniformValueArray(uniformLocation(name), values, count);-
1716}-
1717-
1718-
1719-
1720-
1721-
1722-
1723-
1724void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix3x2 *values, int count)-
1725{-
1726 QOpenGLShaderProgramPrivate * const d = d_func();-
1727 (void)d;;-
1728 if (location == -1 || count <= 0) return; if (sizeof(QMatrix3x2) == sizeof(GLfloat) * 3 * 2) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform2fv(location, count * 3, data); } else { QVarLengthArray<GLfloat> temp(3 * 2 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (3 * 2); ++index2) { temp.data()[3 * 2 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform2fv(location, count * 3, temp.constData()); }-
1729-
1730 ;-
1731}-
1732void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x2 *values, int count)-
1733{-
1734 setUniformValueArray(uniformLocation(name), values, count);-
1735}-
1736-
1737-
1738-
1739-
1740-
1741-
1742-
1743void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix3x3 *values, int count)-
1744{-
1745 QOpenGLShaderProgramPrivate * const d = d_func();-
1746 (void)d;;-
1747 if (location == -1 || count <= 0) return; if (sizeof(QMatrix3x3) == sizeof(GLfloat) * 3 * 3) { d->glfuncs->glUniformMatrix3fv(location, count, 0, reinterpret_cast<const GLfloat *>(values[0].constData())); } else { QVarLengthArray<GLfloat> temp(3 * 3 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (3 * 3); ++index2) { temp.data()[3 * 3 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniformMatrix3fv(location, count, 0, temp.constData()); }-
1748 ;-
1749}-
1750void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x3 *values, int count)-
1751{-
1752 setUniformValueArray(uniformLocation(name), values, count);-
1753}-
1754-
1755-
1756-
1757-
1758-
1759-
1760-
1761void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix3x4 *values, int count)-
1762{-
1763 QOpenGLShaderProgramPrivate * const d = d_func();-
1764 (void)d;;-
1765 if (location == -1 || count <= 0) return; if (sizeof(QMatrix3x4) == sizeof(GLfloat) * 3 * 4) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform4fv(location, count * 3, data); } else { QVarLengthArray<GLfloat> temp(3 * 4 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (3 * 4); ++index2) { temp.data()[3 * 4 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform4fv(location, count * 3, temp.constData()); }-
1766-
1767 ;-
1768}-
1769void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix3x4 *values, int count)-
1770{-
1771 setUniformValueArray(uniformLocation(name), values, count);-
1772}-
1773-
1774-
1775-
1776-
1777-
1778-
1779-
1780void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix4x2 *values, int count)-
1781{-
1782 QOpenGLShaderProgramPrivate * const d = d_func();-
1783 (void)d;;-
1784 if (location == -1 || count <= 0) return; if (sizeof(QMatrix4x2) == sizeof(GLfloat) * 4 * 2) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform2fv(location, count * 4, data); } else { QVarLengthArray<GLfloat> temp(4 * 2 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (4 * 2); ++index2) { temp.data()[4 * 2 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform2fv(location, count * 4, temp.constData()); }-
1785-
1786 ;-
1787}-
1788void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x2 *values, int count)-
1789{-
1790 setUniformValueArray(uniformLocation(name), values, count);-
1791}-
1792-
1793-
1794-
1795-
1796-
1797-
1798-
1799void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix4x3 *values, int count)-
1800{-
1801 QOpenGLShaderProgramPrivate * const d = d_func();-
1802 (void)d;;-
1803 if (location == -1 || count <= 0) return; if (sizeof(QMatrix4x3) == sizeof(GLfloat) * 4 * 3) { const GLfloat *data = reinterpret_cast<const GLfloat *> (values[0].constData()); d->glfuncs->glUniform3fv(location, count * 4, data); } else { QVarLengthArray<GLfloat> temp(4 * 3 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (4 * 3); ++index2) { temp.data()[4 * 3 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniform3fv(location, count * 4, temp.constData()); }-
1804-
1805 ;-
1806}-
1807void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x3 *values, int count)-
1808{-
1809 setUniformValueArray(uniformLocation(name), values, count);-
1810}-
1811-
1812-
1813-
1814-
1815-
1816-
1817-
1818void QOpenGLShaderProgram::setUniformValueArray(int location, const QMatrix4x4 *values, int count)-
1819{-
1820 QOpenGLShaderProgramPrivate * const d = d_func();-
1821 (void)d;;-
1822 if (location == -1 || count <= 0) return; if (sizeof(QMatrix4x4) == sizeof(GLfloat) * 4 * 4) { d->glfuncs->glUniformMatrix4fv(location, count, 0, reinterpret_cast<const GLfloat *>(values[0].constData())); } else { QVarLengthArray<GLfloat> temp(4 * 4 * count); for (int index = 0; index < count; ++index) { for (int index2 = 0; index2 < (4 * 4); ++index2) { temp.data()[4 * 4 * index + index2] = values[index].constData()[index2]; } } d->glfuncs->glUniformMatrix4fv(location, count, 0, temp.constData()); }-
1823 ;-
1824}-
1825void QOpenGLShaderProgram::setUniformValueArray(const char *name, const QMatrix4x4 *values, int count)-
1826{-
1827 setUniformValueArray(uniformLocation(name), values, count);-
1828}-
1829-
1830-
1831-
1832-
1833-
1834int QOpenGLShaderProgram::maxGeometryOutputVertices() const-
1835{-
1836 GLint n = 0;-
1837-
1838 const QOpenGLShaderProgramPrivate * const d = d_func();-
1839 d->glfuncs->glGetIntegerv(0x8DE0, &n);-
1840-
1841 return n;-
1842}-
1843void QOpenGLShaderProgram::setPatchVertexCount(int count)-
1844{-
1845-
1846 QOpenGLShaderProgramPrivate * const d = d_func();-
1847 if (d->tessellationFuncs)-
1848 d->tessellationFuncs->glPatchParameteri(0x8E72, count);-
1849-
1850-
1851-
1852}-
1853int QOpenGLShaderProgram::patchVertexCount() const-
1854{-
1855 int patchVertices = 0;-
1856-
1857 const QOpenGLShaderProgramPrivate * const d = d_func();-
1858 if (d->tessellationFuncs)-
1859 d->tessellationFuncs->glGetIntegerv(0x8E72, &patchVertices);-
1860-
1861 return patchVertices;-
1862}-
1863void QOpenGLShaderProgram::setDefaultOuterTessellationLevels(const QVector<float> &levels)-
1864{-
1865-
1866 QVector<float> tessLevels = levels;-
1867-
1868-
1869-
1870 const int argCount = 4;-
1871 if (tessLevels.size() < argCount) {-
1872 tessLevels.reserve(argCount);-
1873 for (int i = tessLevels.size(); i < argCount; ++i)-
1874 tessLevels.append(1.0f);-
1875 }-
1876-
1877 QOpenGLShaderProgramPrivate * const d = d_func();-
1878 if (d->tessellationFuncs)-
1879 d->tessellationFuncs->glPatchParameterfv(0x8E74, tessLevels.data());-
1880-
1881-
1882-
1883}-
1884QVector<float> QOpenGLShaderProgram::defaultOuterTessellationLevels() const-
1885{-
1886 QVector<float> tessLevels(4, 1.0f);-
1887-
1888 const QOpenGLShaderProgramPrivate * const d = d_func();-
1889 if (d->tessellationFuncs)-
1890 d->tessellationFuncs->glGetFloatv(0x8E74, tessLevels.data());-
1891-
1892 return tessLevels;-
1893}-
1894void QOpenGLShaderProgram::setDefaultInnerTessellationLevels(const QVector<float> &levels)-
1895{-
1896-
1897 QVector<float> tessLevels = levels;-
1898-
1899-
1900-
1901 const int argCount = 2;-
1902 if (tessLevels.size() < argCount) {-
1903 tessLevels.reserve(argCount);-
1904 for (int i = tessLevels.size(); i < argCount; ++i)-
1905 tessLevels.append(1.0f);-
1906 }-
1907-
1908 QOpenGLShaderProgramPrivate * const d = d_func();-
1909 if (d->tessellationFuncs)-
1910 d->tessellationFuncs->glPatchParameterfv(0x8E73, tessLevels.data());-
1911-
1912-
1913-
1914}-
1915QVector<float> QOpenGLShaderProgram::defaultInnerTessellationLevels() const-
1916{-
1917 QVector<float> tessLevels(2, 1.0f);-
1918-
1919 const QOpenGLShaderProgramPrivate * const d = d_func();-
1920 if (d->tessellationFuncs)-
1921 d->tessellationFuncs->glGetFloatv(0x8E73, tessLevels.data());-
1922-
1923 return tessLevels;-
1924}-
1925bool QOpenGLShaderProgram::hasOpenGLShaderPrograms(QOpenGLContext *context)-
1926{-
1927-
1928 if (!context)-
1929 context = QOpenGLContext::currentContext();-
1930 if (!context)-
1931 return false;-
1932 return QOpenGLFunctions(context).hasOpenGLFeature(QOpenGLFunctions::Shaders);-
1933-
1934-
1935-
1936-
1937}-
1938-
1939-
1940-
1941-
1942void QOpenGLShaderProgram::shaderDestroyed()-
1943{-
1944 QOpenGLShaderProgramPrivate * const d = d_func();-
1945 QOpenGLShader *shader = qobject_cast<QOpenGLShader *>(sender());-
1946 if (shader && !d->removingShaders)-
1947 removeShader(shader);-
1948}-
1949bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)-
1950{-
1951 if (!context)-
1952 context = QOpenGLContext::currentContext();-
1953 if (!context)-
1954 return false;-
1955-
1956 if ((type & ~(Geometry | Vertex | Fragment | TessellationControl | TessellationEvaluation | Compute)) || type == 0)-
1957 return false;-
1958-
1959 QSurfaceFormat format = context->format();-
1960 if (type == Geometry) {-
1961-
1962-
1963 QSurfaceFormat format = context->format();-
1964 return (!context->isOpenGLES())-
1965 && (format.version() >= qMakePair<int, int>(3, 2));-
1966-
1967-
1968-
1969-
1970 } else if (type == TessellationControl || type == TessellationEvaluation) {-
1971-
1972 return (!context->isOpenGLES())-
1973 && (format.version() >= qMakePair<int, int>(4, 0));-
1974-
1975-
1976-
1977-
1978 } else if (type == Compute) {-
1979-
1980 return (format.version() >= qMakePair<int, int>(4, 3));-
1981-
1982-
1983-
1984-
1985 }-
1986-
1987-
1988-
1989 return true;-
1990}-
1991-
1992-
Switch to Source codePreprocessed file

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