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