1// Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "graphicshelpergl3_2_p.h"
5
6#if !QT_CONFIG(opengles2)
7#include <QOpenGLFunctions_3_2_Core>
8#include <QOpenGLFunctions_3_3_Core>
9#include <private/attachmentpack_p.h>
10#include <logging_p.h>
11#include <qgraphicsutils_p.h>
12
13QT_BEGIN_NAMESPACE
14
15# ifndef QT_OPENGL_3
16# define GL_PATCH_VERTICES 36466
17# define GL_ACTIVE_RESOURCES 0x92F5
18# define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
19# define GL_BUFFER_BINDING 0x9302
20# define GL_BUFFER_DATA_SIZE 0x9303
21# define GL_NUM_ACTIVE_VARIABLES 0x9304
22# define GL_SHADER_STORAGE_BLOCK 0x92E6
23# define GL_UNIFORM 0x92E1
24# define GL_UNIFORM_BLOCK 0x92E2
25# define GL_UNIFORM_BLOCK_INDEX 0x8A3A
26# define GL_UNIFORM_OFFSET 0x8A3B
27# define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
28# define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
29# define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
30# define GL_UNIFORM_BLOCK_BINDING 0x8A3F
31# define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
32# endif
33
34namespace Qt3DRender {
35namespace Render {
36namespace OpenGL {
37
38GraphicsHelperGL3_2::GraphicsHelperGL3_2()
39 : m_funcs(nullptr)
40{
41}
42
43GraphicsHelperGL3_2::~GraphicsHelperGL3_2()
44{
45}
46
47void GraphicsHelperGL3_2::initializeHelper(QOpenGLContext *context,
48 QAbstractOpenGLFunctions *functions)
49{
50 Q_UNUSED(context);
51 m_funcs = static_cast<QOpenGLFunctions_3_2_Core*>(functions);
52 const bool ok = m_funcs->initializeOpenGLFunctions();
53 Q_ASSERT(ok);
54 Q_UNUSED(ok);
55}
56
57void GraphicsHelperGL3_2::drawElementsInstancedBaseVertexBaseInstance(GLenum primitiveType,
58 GLsizei primitiveCount,
59 GLint indexType,
60 void *indices,
61 GLsizei instances,
62 GLint baseVertex,
63 GLint baseInstance)
64{
65 if (baseInstance != 0)
66 qWarning() << "glDrawElementsInstancedBaseVertexBaseInstance is not supported with OpenGL 3.2";
67
68 // glDrawElements OpenGL 3.1 or greater
69 m_funcs->glDrawElementsInstancedBaseVertex(mode: primitiveType,
70 count: primitiveCount,
71 type: indexType,
72 indices,
73 instancecount: instances,
74 basevertex: baseVertex);
75}
76
77void GraphicsHelperGL3_2::drawArraysInstanced(GLenum primitiveType,
78 GLint first,
79 GLsizei count,
80 GLsizei instances)
81{
82 // glDrawArraysInstanced OpenGL 3.1 or greater
83 m_funcs->glDrawArraysInstanced(mode: primitiveType,
84 first,
85 count,
86 instancecount: instances);
87}
88
89void GraphicsHelperGL3_2::drawArraysInstancedBaseInstance(GLenum primitiveType, GLint first, GLsizei count, GLsizei instances, GLsizei baseInstance)
90{
91 if (baseInstance != 0)
92 qWarning() << "glDrawArraysInstancedBaseInstance is not supported with OpenGL 3";
93 m_funcs->glDrawArraysInstanced(mode: primitiveType,
94 first,
95 count,
96 instancecount: instances);
97}
98
99void GraphicsHelperGL3_2::drawElements(GLenum primitiveType,
100 GLsizei primitiveCount,
101 GLint indexType,
102 void *indices,
103 GLint baseVertex)
104{
105 m_funcs->glDrawElementsBaseVertex(mode: primitiveType,
106 count: primitiveCount,
107 type: indexType,
108 indices,
109 basevertex: baseVertex);
110}
111
112void GraphicsHelperGL3_2::drawArrays(GLenum primitiveType,
113 GLint first,
114 GLsizei count)
115{
116 m_funcs->glDrawArrays(mode: primitiveType,
117 first,
118 count);
119}
120
121void GraphicsHelperGL3_2::drawElementsIndirect(GLenum, GLenum, void *)
122{
123 qWarning() << "Indirect Drawing is not supported with OpenGL 3.2";
124}
125
126void GraphicsHelperGL3_2::drawArraysIndirect(GLenum , void *)
127{
128 qWarning() << "Indirect Drawing is not supported with OpenGL 3.2";
129}
130
131void GraphicsHelperGL3_2::setVerticesPerPatch(GLint verticesPerPatch)
132{
133 Q_UNUSED(verticesPerPatch);
134 qWarning() << "Tessellation not supported";
135}
136
137void GraphicsHelperGL3_2::useProgram(GLuint programId)
138{
139 m_funcs->glUseProgram(program: programId);
140}
141
142std::vector<ShaderUniform> GraphicsHelperGL3_2::programUniformsAndLocations(GLuint programId)
143{
144 std::vector<ShaderUniform> uniforms;
145
146 GLint nbrActiveUniforms = 0;
147 m_funcs->glGetProgramiv(program: programId, GL_ACTIVE_UNIFORMS, params: &nbrActiveUniforms);
148 uniforms.reserve(n: nbrActiveUniforms);
149 char uniformName[256];
150 for (GLint i = 0; i < nbrActiveUniforms; i++) {
151 ShaderUniform uniform;
152 GLsizei uniformNameLength = 0;
153 // Size is 1 for scalar and more for struct or arrays
154 // Type is the GL Type
155 m_funcs->glGetActiveUniform(program: programId, index: i, bufSize: sizeof(uniformName) - 1, length: &uniformNameLength,
156 size: &uniform.m_size, type: &uniform.m_type, name: uniformName);
157 uniformName[sizeof(uniformName) - 1] = '\0';
158 uniform.m_location = m_funcs->glGetUniformLocation(program: programId, name: uniformName);
159 uniform.m_name = QString::fromUtf8(utf8: uniformName, size: uniformNameLength);
160 // Work around for uniform array names that aren't returned with [0] by some drivers
161 if (uniform.m_size > 1 && !uniform.m_name.endsWith(s: QLatin1String("[0]")))
162 uniform.m_name.append(s: QLatin1String("[0]"));
163 m_funcs->glGetActiveUniformsiv(program: programId, uniformCount: 1, uniformIndices: (GLuint*)&i, GL_UNIFORM_BLOCK_INDEX, params: &uniform.m_blockIndex);
164 m_funcs->glGetActiveUniformsiv(program: programId, uniformCount: 1, uniformIndices: (GLuint*)&i, GL_UNIFORM_OFFSET, params: &uniform.m_offset);
165 m_funcs->glGetActiveUniformsiv(program: programId, uniformCount: 1, uniformIndices: (GLuint*)&i, GL_UNIFORM_ARRAY_STRIDE, params: &uniform.m_arrayStride);
166 m_funcs->glGetActiveUniformsiv(program: programId, uniformCount: 1, uniformIndices: (GLuint*)&i, GL_UNIFORM_MATRIX_STRIDE, params: &uniform.m_matrixStride);
167 uniform.m_rawByteSize = uniformByteSize(description: uniform);
168 uniforms.push_back(x: uniform);
169 qCDebug(Rendering) << uniform.m_name << "size" << uniform.m_size
170 << " offset" << uniform.m_offset
171 << " rawSize" << uniform.m_rawByteSize;
172 }
173
174 return uniforms;
175}
176
177std::vector<ShaderAttribute> GraphicsHelperGL3_2::programAttributesAndLocations(GLuint programId)
178{
179 std::vector<ShaderAttribute> attributes;
180 GLint nbrActiveAttributes = 0;
181 m_funcs->glGetProgramiv(program: programId, GL_ACTIVE_ATTRIBUTES, params: &nbrActiveAttributes);
182 attributes.reserve(n: nbrActiveAttributes);
183 char attributeName[256];
184 for (GLint i = 0; i < nbrActiveAttributes; i++) {
185 ShaderAttribute attribute;
186 GLsizei attributeNameLength = 0;
187 // Size is 1 for scalar and more for struct or arrays
188 // Type is the GL Type
189 m_funcs->glGetActiveAttrib(program: programId, index: i, bufSize: sizeof(attributeName) - 1, length: &attributeNameLength,
190 size: &attribute.m_size, type: &attribute.m_type, name: attributeName);
191 attributeName[sizeof(attributeName) - 1] = '\0';
192 attribute.m_location = m_funcs->glGetAttribLocation(program: programId, name: attributeName);
193 attribute.m_name = QString::fromUtf8(utf8: attributeName, size: attributeNameLength);
194 attributes.push_back(x: attribute);
195 }
196 return attributes;
197}
198
199std::vector<ShaderUniformBlock> GraphicsHelperGL3_2::programUniformBlocks(GLuint programId)
200{
201 std::vector<ShaderUniformBlock> blocks;
202 GLint nbrActiveUniformsBlocks = 0;
203 m_funcs->glGetProgramiv(program: programId, GL_ACTIVE_UNIFORM_BLOCKS, params: &nbrActiveUniformsBlocks);
204 blocks.reserve(n: nbrActiveUniformsBlocks);
205 for (GLint i = 0; i < nbrActiveUniformsBlocks; i++) {
206 QByteArray uniformBlockName(256, '\0');
207 GLsizei length = 0;
208 ShaderUniformBlock uniformBlock;
209 m_funcs->glGetActiveUniformBlockName(program: programId, uniformBlockIndex: i, bufSize: 256, length: &length, uniformBlockName: uniformBlockName.data());
210 uniformBlock.m_name = QString::fromUtf8(ba: uniformBlockName.left(n: length));
211 uniformBlock.m_index = i;
212 m_funcs->glGetActiveUniformBlockiv(program: programId, uniformBlockIndex: i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, params: &uniformBlock.m_activeUniformsCount);
213 m_funcs->glGetActiveUniformBlockiv(program: programId, uniformBlockIndex: i, GL_UNIFORM_BLOCK_BINDING, params: &uniformBlock.m_binding);
214 m_funcs->glGetActiveUniformBlockiv(program: programId, uniformBlockIndex: i, GL_UNIFORM_BLOCK_DATA_SIZE, params: &uniformBlock.m_size);
215 blocks.push_back(x: uniformBlock);
216 }
217 return blocks;
218}
219
220std::vector<ShaderStorageBlock> GraphicsHelperGL3_2::programShaderStorageBlocks(GLuint programId)
221{
222 Q_UNUSED(programId);
223 qWarning() << "SSBO are not supported by OpenGL 3.2 (since OpenGL 4.3)";
224 return {};
225}
226
227void GraphicsHelperGL3_2::vertexAttribDivisor(GLuint index, GLuint divisor)
228{
229 Q_UNUSED(index);
230 Q_UNUSED(divisor);
231 qCWarning(Rendering) << "Vertex attribute divisor not available with OpenGL 3.2 core";
232}
233
234void GraphicsHelperGL3_2::vertexAttributePointer(GLenum shaderDataType,
235 GLuint index,
236 GLint size,
237 GLenum type,
238 GLboolean normalized,
239 GLsizei stride,
240 const GLvoid *pointer)
241{
242 switch (shaderDataType) {
243 case GL_FLOAT:
244 case GL_FLOAT_VEC2:
245 case GL_FLOAT_VEC3:
246 case GL_FLOAT_VEC4:
247 case GL_FLOAT_MAT2:
248 case GL_FLOAT_MAT2x3:
249 case GL_FLOAT_MAT2x4:
250 case GL_FLOAT_MAT3:
251 case GL_FLOAT_MAT3x2:
252 case GL_FLOAT_MAT3x4:
253 case GL_FLOAT_MAT4x2:
254 case GL_FLOAT_MAT4x3:
255 case GL_FLOAT_MAT4:
256 m_funcs->glVertexAttribPointer(index, size, type, normalized, stride, pointer);
257 break;
258
259 case GL_INT:
260 case GL_INT_VEC2:
261 case GL_INT_VEC3:
262 case GL_INT_VEC4:
263 case GL_UNSIGNED_INT:
264 case GL_UNSIGNED_INT_VEC2:
265 case GL_UNSIGNED_INT_VEC3:
266 case GL_UNSIGNED_INT_VEC4:
267 m_funcs->glVertexAttribIPointer(index, size, type, stride, pointer);
268 break;
269
270 default:
271 qCWarning(Rendering) << "vertexAttribPointer: Unhandled type";
272 Q_UNREACHABLE();
273 }
274}
275
276void GraphicsHelperGL3_2::readBuffer(GLenum mode)
277{
278 m_funcs->glReadBuffer(mode);
279}
280
281void GraphicsHelperGL3_2::drawBuffer(GLenum mode)
282{
283 m_funcs->glDrawBuffer(mode);
284}
285
286void *GraphicsHelperGL3_2::fenceSync()
287{
288 return m_funcs->glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, flags: 0);
289}
290
291void GraphicsHelperGL3_2::clientWaitSync(void *sync, GLuint64 nanoSecTimeout)
292{
293 m_funcs->glClientWaitSync(sync: static_cast<GLsync>(sync), GL_SYNC_FLUSH_COMMANDS_BIT, timeout: nanoSecTimeout);
294}
295
296void GraphicsHelperGL3_2::waitSync(void *sync)
297{
298 m_funcs->glWaitSync(sync: static_cast<GLsync>(sync), flags: 0, GL_TIMEOUT_IGNORED);
299}
300
301bool GraphicsHelperGL3_2::wasSyncSignaled(void *sync)
302{
303 GLint v;
304 m_funcs->glGetSynciv(sync: static_cast<GLsync>(sync),
305 GL_SYNC_STATUS,
306 bufSize: sizeof(v),
307 length: nullptr,
308 values: &v);
309 return v == GL_SIGNALED;
310}
311
312void GraphicsHelperGL3_2::deleteSync(void *sync)
313{
314 m_funcs->glDeleteSync(sync: static_cast<GLsync>(sync));
315}
316
317void GraphicsHelperGL3_2::rasterMode(GLenum faceMode, GLenum rasterMode)
318{
319 m_funcs->glPolygonMode(face: faceMode, mode: rasterMode);
320}
321
322void GraphicsHelperGL3_2::blendEquation(GLenum mode)
323{
324 m_funcs->glBlendEquation(mode);
325}
326
327void GraphicsHelperGL3_2::blendFunci(GLuint buf, GLenum sfactor, GLenum dfactor)
328{
329 Q_UNUSED(buf);
330 Q_UNUSED(sfactor);
331 Q_UNUSED(dfactor);
332
333 qWarning() << "glBlendFunci() not supported by OpenGL 3.0 (since OpenGL 4.0)";
334}
335
336void GraphicsHelperGL3_2::blendFuncSeparatei(GLuint buf, GLenum sRGB, GLenum dRGB, GLenum sAlpha, GLenum dAlpha)
337{
338 Q_UNUSED(buf);
339 Q_UNUSED(sRGB);
340 Q_UNUSED(dRGB);
341 Q_UNUSED(sAlpha);
342 Q_UNUSED(dAlpha);
343
344 qWarning() << "glBlendFuncSeparatei() not supported by OpenGL 3.0 (since OpenGL 4.0)";
345}
346
347void GraphicsHelperGL3_2::alphaTest(GLenum, GLenum)
348{
349 qCWarning(Rendering) << "AlphaTest not available with OpenGL 3.2 core";
350}
351
352void GraphicsHelperGL3_2::depthTest(GLenum mode)
353{
354 m_funcs->glEnable(GL_DEPTH_TEST);
355 m_funcs->glDepthFunc(func: mode);
356}
357
358void GraphicsHelperGL3_2::depthMask(GLenum mode)
359{
360 m_funcs->glDepthMask(flag: mode);
361}
362
363void GraphicsHelperGL3_2::depthRange(GLdouble nearValue, GLdouble farValue)
364{
365 m_funcs->glDepthRange(nearVal: nearValue, farVal: farValue);
366}
367
368void GraphicsHelperGL3_2::frontFace(GLenum mode)
369{
370 m_funcs->glFrontFace(mode);
371
372}
373
374void GraphicsHelperGL3_2::setMSAAEnabled(bool enabled)
375{
376 enabled ? m_funcs->glEnable(GL_MULTISAMPLE)
377 : m_funcs->glDisable(GL_MULTISAMPLE);
378}
379
380void GraphicsHelperGL3_2::setAlphaCoverageEnabled(bool enabled)
381{
382 enabled ? m_funcs->glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE)
383 : m_funcs->glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
384}
385
386GLuint GraphicsHelperGL3_2::createFrameBufferObject()
387{
388 GLuint id;
389 m_funcs->glGenFramebuffers(n: 1, framebuffers: &id);
390 return id;
391}
392
393void GraphicsHelperGL3_2::releaseFrameBufferObject(GLuint frameBufferId)
394{
395 m_funcs->glDeleteFramebuffers(n: 1, framebuffers: &frameBufferId);
396}
397
398void GraphicsHelperGL3_2::bindFrameBufferObject(GLuint frameBufferId, FBOBindMode mode)
399{
400 switch (mode) {
401 case FBODraw:
402 m_funcs->glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer: frameBufferId);
403 return;
404 case FBORead:
405 m_funcs->glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer: frameBufferId);
406 return;
407 case FBOReadAndDraw:
408 default:
409 m_funcs->glBindFramebuffer(GL_FRAMEBUFFER, framebuffer: frameBufferId);
410 return;
411 }
412}
413
414void GraphicsHelperGL3_2::bindImageTexture(GLuint imageUnit, GLuint texture,
415 GLint mipLevel, GLboolean layered,
416 GLint layer, GLenum access, GLenum format)
417{
418 Q_UNUSED(imageUnit);
419 Q_UNUSED(texture);
420 Q_UNUSED(mipLevel);
421 Q_UNUSED(layered);
422 Q_UNUSED(layer);
423 Q_UNUSED(access);
424 Q_UNUSED(format);
425 qWarning() << "Shader Images are not supported by OpenGL 3.2 (since OpenGL 4.2)";
426
427}
428
429GLuint GraphicsHelperGL3_2::boundFrameBufferObject()
430{
431 GLint id = 0;
432 m_funcs->glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, params: &id);
433 return id;
434}
435
436bool GraphicsHelperGL3_2::checkFrameBufferComplete()
437{
438 return (m_funcs->glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE);
439}
440
441bool GraphicsHelperGL3_2::frameBufferNeedsRenderBuffer(const Attachment &attachment)
442{
443 Q_UNUSED(attachment);
444 return false;
445}
446
447void GraphicsHelperGL3_2::bindFrameBufferAttachment(QOpenGLTexture *texture, const Attachment &attachment)
448{
449 GLenum attr = GL_DEPTH_STENCIL_ATTACHMENT;
450
451 if (attachment.m_point <= QRenderTargetOutput::Color15)
452 attr = GL_COLOR_ATTACHMENT0 + attachment.m_point;
453 else if (attachment.m_point == QRenderTargetOutput::Depth)
454 attr = GL_DEPTH_ATTACHMENT;
455 else if (attachment.m_point == QRenderTargetOutput::Stencil)
456 attr = GL_STENCIL_ATTACHMENT;
457
458 texture->bind();
459 QOpenGLTexture::Target target = texture->target();
460 if (target == QOpenGLTexture::Target1DArray || target == QOpenGLTexture::Target2DArray ||
461 target == QOpenGLTexture::Target2DMultisampleArray || target == QOpenGLTexture::Target3D)
462 m_funcs->glFramebufferTextureLayer(GL_DRAW_FRAMEBUFFER, attachment: attr, texture: texture->textureId(), level: attachment.m_mipLevel, layer: attachment.m_layer);
463 else if (target == QOpenGLTexture::TargetCubeMapArray && attachment.m_face != QAbstractTexture::AllFaces)
464 m_funcs->glFramebufferTextureLayer( GL_DRAW_FRAMEBUFFER, attachment: attr, texture: texture->textureId(), level: attachment.m_mipLevel, layer: attachment.m_layer * 6 + (attachment.m_face - QAbstractTexture::CubeMapPositiveX));
465 else if (target == QOpenGLTexture::TargetCubeMap)
466 m_funcs->glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment: attr, textarget: attachment.m_face, texture: texture->textureId(), level: attachment.m_mipLevel);
467 else
468 m_funcs->glFramebufferTexture(GL_DRAW_FRAMEBUFFER, attachment: attr, texture: texture->textureId(), level: attachment.m_mipLevel);
469 texture->release();
470}
471
472void GraphicsHelperGL3_2::bindFrameBufferAttachment(RenderBuffer *renderBuffer, const Attachment &attachment)
473{
474 Q_UNUSED(renderBuffer);
475 Q_UNUSED(attachment);
476 Q_UNREACHABLE();
477}
478
479bool GraphicsHelperGL3_2::supportsFeature(GraphicsHelperInterface::Feature feature) const
480{
481 switch (feature) {
482 case MRT:
483 case UniformBufferObject:
484 case PrimitiveRestart:
485 case RenderBufferDimensionRetrieval:
486 case TextureDimensionRetrieval:
487 case BindableFragmentOutputs:
488 case BlitFramebuffer:
489 case Fences:
490 return true;
491 default:
492 return false;
493 }
494}
495
496void GraphicsHelperGL3_2::drawBuffers(GLsizei n, const GLenum *bufs)
497{
498 m_funcs->glDrawBuffers(n, bufs);
499}
500
501void GraphicsHelperGL3_2::bindFragDataLocation(GLuint shader, const QHash<QString, int> &outputs)
502{
503 for (auto it = outputs.begin(), end = outputs.end(); it != end; ++it)
504 m_funcs->glBindFragDataLocation(program: shader, color: it.value(), name: it.key().toStdString().c_str());
505}
506
507void GraphicsHelperGL3_2::bindUniformBlock(GLuint programId, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
508{
509 m_funcs->glUniformBlockBinding(program: programId, uniformBlockIndex, uniformBlockBinding);
510}
511
512void GraphicsHelperGL3_2::bindShaderStorageBlock(GLuint programId, GLuint shaderStorageBlockIndex, GLuint shaderStorageBlockBinding)
513{
514 Q_UNUSED(programId);
515 Q_UNUSED(shaderStorageBlockIndex);
516 Q_UNUSED(shaderStorageBlockBinding);
517 qWarning() << "SSBO are not supported by OpenGL 3.0 (since OpenGL 4.3)";
518}
519
520void GraphicsHelperGL3_2::bindBufferBase(GLenum target, GLuint index, GLuint buffer)
521{
522 m_funcs->glBindBufferBase(target, index, buffer);
523}
524
525void GraphicsHelperGL3_2::buildUniformBuffer(const QVariant &v, const ShaderUniform &description, QByteArray &buffer)
526{
527 char *bufferData = buffer.data();
528
529 switch (description.m_type) {
530
531 case GL_FLOAT: {
532 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 1);
533 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 1);
534 break;
535 }
536
537 case GL_FLOAT_VEC2: {
538 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 2);
539 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 2);
540 break;
541 }
542
543 case GL_FLOAT_VEC3: {
544 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 3);
545 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 3);
546 break;
547 }
548
549 case GL_FLOAT_VEC4: {
550 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 4);
551 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 4);
552 break;
553 }
554
555 case GL_FLOAT_MAT2: {
556 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 4);
557 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 2, rows: 2);
558 break;
559 }
560
561 case GL_FLOAT_MAT2x3: {
562 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 6);
563 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 2, rows: 3);
564 break;
565 }
566
567 case GL_FLOAT_MAT2x4: {
568 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 8);
569 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 2, rows: 4);
570 break;
571 }
572
573 case GL_FLOAT_MAT3: {
574 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 9);
575 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 3, rows: 3);
576 break;
577 }
578
579 case GL_FLOAT_MAT3x2: {
580 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 6);
581 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 3, rows: 2);
582 break;
583 }
584
585 case GL_FLOAT_MAT3x4: {
586 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 12);
587 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 3, rows: 4);
588 break;
589 }
590
591 case GL_FLOAT_MAT4: {
592 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 16);
593 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 4, rows: 4);
594 break;
595 }
596
597 case GL_FLOAT_MAT4x2: {
598 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 8);
599 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 4, rows: 2);
600 break;
601 }
602
603 case GL_FLOAT_MAT4x3: {
604 const GLfloat *data = QGraphicsUtils::valueArrayFromVariant<GLfloat>(v, count: description.m_size, tupleSize: 12);
605 QGraphicsUtils::fillDataMatrixArray(buffer: bufferData, data, description, cols: 4, rows: 3);
606 break;
607 }
608
609 case GL_INT: {
610 const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, count: description.m_size, tupleSize: 1);
611 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 1);
612 break;
613 }
614
615 case GL_INT_VEC2: {
616 const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, count: description.m_size, tupleSize: 2);
617 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 2);
618 break;
619 }
620
621 case GL_INT_VEC3: {
622 const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, count: description.m_size, tupleSize: 3);
623 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 3);
624 break;
625 }
626
627 case GL_INT_VEC4: {
628 const GLint *data = QGraphicsUtils::valueArrayFromVariant<GLint>(v, count: description.m_size, tupleSize: 4);
629 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 4);
630 break;
631 }
632
633 case GL_UNSIGNED_INT: {
634 const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, count: description.m_size, tupleSize: 1);
635 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 1);
636 break;
637 }
638
639 case GL_UNSIGNED_INT_VEC2: {
640 const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, count: description.m_size, tupleSize: 2);
641 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 2);
642 break;
643 }
644
645 case GL_UNSIGNED_INT_VEC3: {
646 const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, count: description.m_size, tupleSize: 3);
647 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 3);
648 break;
649 }
650
651 case GL_UNSIGNED_INT_VEC4: {
652 const GLuint *data = QGraphicsUtils::valueArrayFromVariant<GLuint>(v, count: description.m_size, tupleSize: 4);
653 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 4);
654 break;
655 }
656
657 case GL_BOOL: {
658 const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, count: description.m_size, tupleSize: 1);
659 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 1);
660 break;
661 }
662
663 case GL_BOOL_VEC2: {
664 const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, count: description.m_size, tupleSize: 2);
665 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 2);
666 break;
667 }
668
669 case GL_BOOL_VEC3: {
670 const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, count: description.m_size, tupleSize: 3);
671 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 3);
672 break;
673 }
674
675 case GL_BOOL_VEC4: {
676 const GLboolean *data = QGraphicsUtils::valueArrayFromVariant<GLboolean>(v, count: description.m_size, tupleSize: 4);
677 QGraphicsUtils::fillDataArray(buffer: bufferData, data, description, tupleSize: 4);
678 break;
679 }
680
681 case GL_SAMPLER_1D:
682 case GL_SAMPLER_2D:
683 case GL_SAMPLER_3D:
684 case GL_SAMPLER_CUBE:
685 case GL_SAMPLER_BUFFER:
686 case GL_SAMPLER_2D_RECT:
687 case GL_INT_SAMPLER_1D:
688 case GL_INT_SAMPLER_2D:
689 case GL_INT_SAMPLER_3D:
690 case GL_INT_SAMPLER_CUBE:
691 case GL_INT_SAMPLER_BUFFER:
692 case GL_INT_SAMPLER_2D_RECT:
693 case GL_UNSIGNED_INT_SAMPLER_1D:
694 case GL_UNSIGNED_INT_SAMPLER_2D:
695 case GL_UNSIGNED_INT_SAMPLER_3D:
696 case GL_UNSIGNED_INT_SAMPLER_CUBE:
697 case GL_UNSIGNED_INT_SAMPLER_BUFFER:
698 case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
699 case GL_SAMPLER_1D_SHADOW:
700 case GL_SAMPLER_2D_SHADOW:
701 case GL_SAMPLER_CUBE_SHADOW:
702 case GL_SAMPLER_1D_ARRAY:
703 case GL_SAMPLER_2D_ARRAY:
704 case GL_INT_SAMPLER_1D_ARRAY:
705 case GL_INT_SAMPLER_2D_ARRAY:
706 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
707 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
708 case GL_SAMPLER_1D_ARRAY_SHADOW:
709 case GL_SAMPLER_2D_ARRAY_SHADOW:
710 case GL_SAMPLER_2D_RECT_SHADOW:
711 case GL_SAMPLER_2D_MULTISAMPLE:
712 case GL_INT_SAMPLER_2D_MULTISAMPLE:
713 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
714 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
715 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
716 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY: {
717 Q_ASSERT(description.m_size == 1);
718 int value = v.toInt();
719 QGraphicsUtils::fillDataArray<GLint>(buffer: bufferData, data: &value, description, tupleSize: 1);
720 break;
721 }
722
723 default:
724 qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
725 break;
726 }
727}
728
729uint GraphicsHelperGL3_2::uniformByteSize(const ShaderUniform &description)
730{
731 uint rawByteSize = 0;
732 int arrayStride = qMax(a: description.m_arrayStride, b: 0);
733 int matrixStride = qMax(a: description.m_matrixStride, b: 0);
734
735 switch (description.m_type) {
736
737 case GL_FLOAT_VEC2:
738 case GL_INT_VEC2:
739 case GL_UNSIGNED_INT_VEC2:
740 rawByteSize = 8;
741 break;
742
743 case GL_FLOAT_VEC3:
744 case GL_INT_VEC3:
745 case GL_UNSIGNED_INT_VEC3:
746 rawByteSize = 12;
747 break;
748
749 case GL_FLOAT_VEC4:
750 case GL_INT_VEC4:
751 case GL_UNSIGNED_INT_VEC4:
752 rawByteSize = 16;
753 break;
754
755 case GL_FLOAT_MAT2:
756 rawByteSize = matrixStride ? 2 * matrixStride : 16;
757 break;
758
759 case GL_FLOAT_MAT2x4:
760 rawByteSize = matrixStride ? 2 * matrixStride : 32;
761 break;
762
763 case GL_FLOAT_MAT4x2:
764 rawByteSize = matrixStride ? 4 * matrixStride : 32;
765 break;
766
767 case GL_FLOAT_MAT3:
768 rawByteSize = matrixStride ? 3 * matrixStride : 36;
769 break;
770
771 case GL_FLOAT_MAT2x3:
772 rawByteSize = matrixStride ? 2 * matrixStride : 24;
773 break;
774
775 case GL_FLOAT_MAT3x2:
776 rawByteSize = matrixStride ? 3 * matrixStride : 24;
777 break;
778
779 case GL_FLOAT_MAT4:
780 rawByteSize = matrixStride ? 4 * matrixStride : 64;
781 break;
782
783 case GL_FLOAT_MAT4x3:
784 rawByteSize = matrixStride ? 4 * matrixStride : 48;
785 break;
786
787 case GL_FLOAT_MAT3x4:
788 rawByteSize = matrixStride ? 3 * matrixStride : 48;
789 break;
790
791 case GL_BOOL:
792 rawByteSize = 1;
793 break;
794
795 case GL_BOOL_VEC2:
796 rawByteSize = 2;
797 break;
798
799 case GL_BOOL_VEC3:
800 rawByteSize = 3;
801 break;
802
803 case GL_BOOL_VEC4:
804 rawByteSize = 4;
805 break;
806
807 case GL_INT:
808 case GL_FLOAT:
809 case GL_UNSIGNED_INT:
810 case GL_SAMPLER_1D:
811 case GL_SAMPLER_2D:
812 case GL_SAMPLER_3D:
813 case GL_SAMPLER_CUBE:
814 case GL_SAMPLER_BUFFER:
815 case GL_SAMPLER_2D_RECT:
816 case GL_INT_SAMPLER_1D:
817 case GL_INT_SAMPLER_2D:
818 case GL_INT_SAMPLER_3D:
819 case GL_INT_SAMPLER_CUBE:
820 case GL_INT_SAMPLER_BUFFER:
821 case GL_INT_SAMPLER_2D_RECT:
822 case GL_UNSIGNED_INT_SAMPLER_1D:
823 case GL_UNSIGNED_INT_SAMPLER_2D:
824 case GL_UNSIGNED_INT_SAMPLER_3D:
825 case GL_UNSIGNED_INT_SAMPLER_CUBE:
826 case GL_UNSIGNED_INT_SAMPLER_BUFFER:
827 case GL_UNSIGNED_INT_SAMPLER_2D_RECT:
828 case GL_SAMPLER_1D_SHADOW:
829 case GL_SAMPLER_2D_SHADOW:
830 case GL_SAMPLER_CUBE_SHADOW:
831 case GL_SAMPLER_1D_ARRAY:
832 case GL_SAMPLER_2D_ARRAY:
833 case GL_INT_SAMPLER_1D_ARRAY:
834 case GL_INT_SAMPLER_2D_ARRAY:
835 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
836 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
837 case GL_SAMPLER_1D_ARRAY_SHADOW:
838 case GL_SAMPLER_2D_ARRAY_SHADOW:
839 case GL_SAMPLER_2D_RECT_SHADOW:
840 case GL_SAMPLER_2D_MULTISAMPLE:
841 case GL_INT_SAMPLER_2D_MULTISAMPLE:
842 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
843 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
844 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
845 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
846 rawByteSize = 4;
847 break;
848 }
849
850 return arrayStride ? rawByteSize * arrayStride : rawByteSize;
851}
852
853void GraphicsHelperGL3_2::enableClipPlane(int clipPlane)
854{
855 m_funcs->glEnable(GL_CLIP_DISTANCE0 + clipPlane);
856}
857
858void GraphicsHelperGL3_2::disableClipPlane(int clipPlane)
859{
860 m_funcs->glDisable(GL_CLIP_DISTANCE0 + clipPlane);
861}
862
863void GraphicsHelperGL3_2::setClipPlane(int clipPlane, const QVector3D &normal, float distance)
864{
865 // deprecated
866 Q_UNUSED(clipPlane);
867 Q_UNUSED(normal);
868 Q_UNUSED(distance);
869}
870
871GLint GraphicsHelperGL3_2::maxClipPlaneCount()
872{
873 GLint max = 0;
874 m_funcs->glGetIntegerv(GL_MAX_CLIP_DISTANCES, params: &max);
875 return max;
876}
877
878void GraphicsHelperGL3_2::memoryBarrier(QMemoryBarrier::Operations barriers)
879{
880 Q_UNUSED(barriers);
881 qWarning() << "memory barrier is not supported by OpenGL 3.0 (since 4.3)";
882}
883
884void GraphicsHelperGL3_2::enablePrimitiveRestart(int primitiveRestartIndex)
885{
886 m_funcs->glPrimitiveRestartIndex(index: primitiveRestartIndex);
887 m_funcs->glEnable(GL_PRIMITIVE_RESTART);
888}
889
890void GraphicsHelperGL3_2::enableVertexAttributeArray(int location)
891{
892 m_funcs->glEnableVertexAttribArray(index: location);
893}
894
895void GraphicsHelperGL3_2::disablePrimitiveRestart()
896{
897 m_funcs->glDisable(GL_PRIMITIVE_RESTART);
898}
899
900void GraphicsHelperGL3_2::clearBufferf(GLint drawbuffer, const QVector4D &values)
901{
902 GLfloat vec[4] = {values[0], values[1], values[2], values[3]};
903 m_funcs->glClearBufferfv(GL_COLOR, drawbuffer, value: vec);
904}
905
906void GraphicsHelperGL3_2::pointSize(bool programmable, GLfloat value)
907{
908 if (programmable) {
909 m_funcs->glEnable(GL_PROGRAM_POINT_SIZE);
910 } else {
911 m_funcs->glDisable(GL_PROGRAM_POINT_SIZE);
912 m_funcs->glPointSize(size: value);
913 }
914}
915
916void GraphicsHelperGL3_2::enablei(GLenum cap, GLuint index)
917{
918 m_funcs->glEnablei(target: cap, index);
919}
920
921void GraphicsHelperGL3_2::disablei(GLenum cap, GLuint index)
922{
923 m_funcs->glDisablei(target: cap, index);
924}
925
926void GraphicsHelperGL3_2::setSeamlessCubemap(bool enable)
927{
928 if (enable)
929 m_funcs->glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
930 else
931 m_funcs->glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
932}
933
934QSize GraphicsHelperGL3_2::getRenderBufferDimensions(GLuint renderBufferId)
935{
936 GLint width = 0;
937 GLint height = 0;
938
939 m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer: renderBufferId);
940 m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, params: &width);
941 m_funcs->glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, params: &height);
942 m_funcs->glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer: 0);
943
944 return QSize(width, height);
945}
946
947QSize GraphicsHelperGL3_2::getTextureDimensions(GLuint textureId, GLenum target, uint level)
948{
949 GLint width = 0;
950 GLint height = 0;
951
952 m_funcs->glBindTexture(target, texture: textureId);
953 m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, params: &width);
954 m_funcs->glGetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, params: &height);
955 m_funcs->glBindTexture(target, texture: 0);
956
957 return QSize(width, height);
958}
959
960void GraphicsHelperGL3_2::dispatchCompute(GLuint wx, GLuint wy, GLuint wz)
961{
962 Q_UNUSED(wx);
963 Q_UNUSED(wy);
964 Q_UNUSED(wz);
965 qWarning() << "Compute Shaders are not supported by OpenGL 3.2 (since OpenGL 4.3)";
966}
967
968char *GraphicsHelperGL3_2::mapBuffer(GLenum target, GLsizeiptr size)
969{
970 return static_cast<char*>(m_funcs->glMapBufferRange(target, offset: 0, length: size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT));
971}
972
973GLboolean GraphicsHelperGL3_2::unmapBuffer(GLenum target)
974{
975 return m_funcs->glUnmapBuffer(target);
976}
977
978void GraphicsHelperGL3_2::glUniform1fv(GLint location, GLsizei count, const GLfloat *values)
979{
980 m_funcs->glUniform1fv(location, count, value: values);
981}
982
983void GraphicsHelperGL3_2::glUniform2fv(GLint location, GLsizei count, const GLfloat *values)
984{
985 m_funcs->glUniform2fv(location, count, value: values);
986}
987
988void GraphicsHelperGL3_2::glUniform3fv(GLint location, GLsizei count, const GLfloat *values)
989{
990 m_funcs->glUniform3fv(location, count, value: values);
991}
992
993void GraphicsHelperGL3_2::glUniform4fv(GLint location, GLsizei count, const GLfloat *values)
994{
995 m_funcs->glUniform4fv(location, count, value: values);
996}
997
998void GraphicsHelperGL3_2::glUniform1iv(GLint location, GLsizei count, const GLint *values)
999{
1000 m_funcs->glUniform1iv(location, count, value: values);
1001}
1002
1003void GraphicsHelperGL3_2::glUniform2iv(GLint location, GLsizei count, const GLint *values)
1004{
1005 m_funcs->glUniform2iv(location, count, value: values);
1006}
1007
1008void GraphicsHelperGL3_2::glUniform3iv(GLint location, GLsizei count, const GLint *values)
1009{
1010 m_funcs->glUniform3iv(location, count, value: values);
1011}
1012
1013void GraphicsHelperGL3_2::glUniform4iv(GLint location, GLsizei count, const GLint *values)
1014{
1015 m_funcs->glUniform4iv(location, count, value: values);
1016}
1017
1018void GraphicsHelperGL3_2::glUniform1uiv(GLint location, GLsizei count, const GLuint *values)
1019{
1020 m_funcs->glUniform1uiv(location, count, value: values);
1021}
1022
1023void GraphicsHelperGL3_2::glUniform2uiv(GLint location, GLsizei count, const GLuint *values)
1024{
1025 m_funcs->glUniform2uiv(location, count, value: values);
1026}
1027
1028void GraphicsHelperGL3_2::glUniform3uiv(GLint location, GLsizei count, const GLuint *values)
1029{
1030 m_funcs->glUniform3uiv(location, count, value: values);
1031}
1032
1033void GraphicsHelperGL3_2::glUniform4uiv(GLint location, GLsizei count, const GLuint *values)
1034{
1035 m_funcs->glUniform4uiv(location, count, value: values);
1036}
1037
1038void GraphicsHelperGL3_2::glUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *values)
1039{
1040 m_funcs->glUniformMatrix2fv(location, count, transpose: false, value: values);
1041}
1042
1043void GraphicsHelperGL3_2::glUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *values)
1044{
1045 m_funcs->glUniformMatrix3fv(location, count, transpose: false, value: values);
1046}
1047
1048void GraphicsHelperGL3_2::glUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *values)
1049{
1050 m_funcs->glUniformMatrix4fv(location, count, transpose: false, value: values);
1051}
1052
1053void GraphicsHelperGL3_2::glUniformMatrix2x3fv(GLint location, GLsizei count, const GLfloat *values)
1054{
1055 m_funcs->glUniformMatrix2x3fv(location, count, transpose: false, value: values);
1056}
1057
1058void GraphicsHelperGL3_2::glUniformMatrix3x2fv(GLint location, GLsizei count, const GLfloat *values)
1059{
1060 m_funcs->glUniformMatrix3x2fv(location, count, transpose: false, value: values);
1061}
1062
1063void GraphicsHelperGL3_2::glUniformMatrix2x4fv(GLint location, GLsizei count, const GLfloat *values)
1064{
1065 m_funcs->glUniformMatrix2x4fv(location, count, transpose: false, value: values);
1066}
1067
1068void GraphicsHelperGL3_2::glUniformMatrix4x2fv(GLint location, GLsizei count, const GLfloat *values)
1069{
1070 m_funcs->glUniformMatrix4x2fv(location, count, transpose: false, value: values);
1071}
1072
1073void GraphicsHelperGL3_2::glUniformMatrix3x4fv(GLint location, GLsizei count, const GLfloat *values)
1074{
1075 m_funcs->glUniformMatrix3x4fv(location, count, transpose: false, value: values);
1076}
1077
1078void GraphicsHelperGL3_2::glUniformMatrix4x3fv(GLint location, GLsizei count, const GLfloat *values)
1079{
1080 m_funcs->glUniformMatrix4x3fv(location, count, transpose: false, value: values);
1081}
1082
1083UniformType GraphicsHelperGL3_2::uniformTypeFromGLType(GLenum type)
1084{
1085 switch (type) {
1086 case GL_FLOAT:
1087 return UniformType::Float;
1088 case GL_FLOAT_VEC2:
1089 return UniformType::Vec2;
1090 case GL_FLOAT_VEC3:
1091 return UniformType::Vec3;
1092 case GL_FLOAT_VEC4:
1093 return UniformType::Vec4;
1094 case GL_FLOAT_MAT2:
1095 return UniformType::Mat2;
1096 case GL_FLOAT_MAT3:
1097 return UniformType::Mat3;
1098 case GL_FLOAT_MAT4:
1099 return UniformType::Mat4;
1100 case GL_FLOAT_MAT2x3:
1101 return UniformType::Mat2x3;
1102 case GL_FLOAT_MAT3x2:
1103 return UniformType::Mat3x2;
1104 case GL_FLOAT_MAT2x4:
1105 return UniformType::Mat2x4;
1106 case GL_FLOAT_MAT4x2:
1107 return UniformType::Mat4x2;
1108 case GL_FLOAT_MAT3x4:
1109 return UniformType::Mat3x4;
1110 case GL_FLOAT_MAT4x3:
1111 return UniformType::Mat4x3;
1112 case GL_INT:
1113 return UniformType::Int;
1114 case GL_INT_VEC2:
1115 return UniformType::IVec2;
1116 case GL_INT_VEC3:
1117 return UniformType::IVec3;
1118 case GL_INT_VEC4:
1119 return UniformType::IVec4;
1120 case GL_UNSIGNED_INT:
1121 return UniformType::UInt;
1122 case GL_UNSIGNED_INT_VEC2:
1123 return UniformType::UIVec2;
1124 case GL_UNSIGNED_INT_VEC3:
1125 return UniformType::UIVec3;
1126 case GL_UNSIGNED_INT_VEC4:
1127 return UniformType::UIVec4;
1128 case GL_BOOL:
1129 return UniformType::Bool;
1130 case GL_BOOL_VEC2:
1131 return UniformType::BVec2;
1132 case GL_BOOL_VEC3:
1133 return UniformType::BVec3;
1134 case GL_BOOL_VEC4:
1135 return UniformType::BVec4;
1136
1137 case GL_SAMPLER_BUFFER:
1138 case GL_SAMPLER_1D:
1139 case GL_SAMPLER_1D_SHADOW:
1140 case GL_SAMPLER_2D:
1141 case GL_SAMPLER_2D_RECT:
1142 case GL_SAMPLER_2D_SHADOW:
1143 case GL_SAMPLER_2D_RECT_SHADOW:
1144 case GL_SAMPLER_CUBE:
1145 case GL_SAMPLER_CUBE_SHADOW:
1146 case GL_SAMPLER_1D_ARRAY:
1147 case GL_SAMPLER_2D_ARRAY:
1148 case GL_SAMPLER_2D_ARRAY_SHADOW:
1149 case GL_SAMPLER_2D_MULTISAMPLE:
1150 case GL_SAMPLER_2D_MULTISAMPLE_ARRAY:
1151 case GL_SAMPLER_3D:
1152 case GL_INT_SAMPLER_BUFFER:
1153 case GL_INT_SAMPLER_1D:
1154 case GL_INT_SAMPLER_2D:
1155 case GL_INT_SAMPLER_3D:
1156 case GL_INT_SAMPLER_CUBE:
1157 case GL_INT_SAMPLER_1D_ARRAY:
1158 case GL_INT_SAMPLER_2D_ARRAY:
1159 case GL_INT_SAMPLER_2D_MULTISAMPLE:
1160 case GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
1161 case GL_UNSIGNED_INT_SAMPLER_BUFFER:
1162 case GL_UNSIGNED_INT_SAMPLER_1D:
1163 case GL_UNSIGNED_INT_SAMPLER_2D:
1164 case GL_UNSIGNED_INT_SAMPLER_3D:
1165 case GL_UNSIGNED_INT_SAMPLER_CUBE:
1166 case GL_UNSIGNED_INT_SAMPLER_1D_ARRAY:
1167 case GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
1168 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
1169 case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY:
1170 return UniformType::Sampler;
1171 default:
1172 Q_UNREACHABLE_RETURN(UniformType::Float);
1173 }
1174}
1175
1176void GraphicsHelperGL3_2::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter)
1177{
1178 m_funcs->glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
1179}
1180
1181} // namespace OpenGL
1182} // namespace Render
1183} // namespace Qt3DRender
1184
1185QT_END_NAMESPACE
1186
1187#endif // !QT_OPENGL_ES_2
1188

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

source code of qt3d/src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp