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