summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-18 15:27:38 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-18 15:25:32 +0000
commitb38d0ac85cd50dea00cf97e01c086dea4ac4ebc5 (patch)
tree819ed5225df9948097c1d00991682c1c4a709df1 /src
parentc9690153248f1cc8842e97472721bd22e411ada8 (diff)
Make shadow mapping functional on ES 3
To preserve our sanity we will only support ES 3.x, not 2.0 + GL_OES_depth_texture + EXT_shadow_samplers. This way we can provide version 300 es shaders and do not have to introduce yet another filter and technique. Change-Id: Ib5c826d6540b4848f0cb4629e5311150169a9697 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/render/backend/qgraphicshelperes2.cpp33
-rw-r--r--src/render/backend/qgraphicshelperes2_p.h1
2 files changed, 34 insertions, 0 deletions
diff --git a/src/render/backend/qgraphicshelperes2.cpp b/src/render/backend/qgraphicshelperes2.cpp
index 72190ea15..37cac786d 100644
--- a/src/render/backend/qgraphicshelperes2.cpp
+++ b/src/render/backend/qgraphicshelperes2.cpp
@@ -41,6 +41,23 @@
QT_BEGIN_NAMESPACE
+// ES 3.0+
+#ifndef GL_SAMPLER_3D
+#define GL_SAMPLER_3D 0x8B5F
+#endif
+#ifndef GL_SAMPLER_2D_SHADOW
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#endif
+#ifndef GL_SAMPLER_CUBE_SHADOW
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#endif
+#ifndef GL_SAMPLER_2D_ARRAY
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#endif
+#ifndef GL_SAMPLER_2D_ARRAY_SHADOW
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#endif
+
namespace Qt3D {
namespace Render {
@@ -59,6 +76,7 @@ void QGraphicsHelperES2::initializeHelper(QOpenGLContext *context,
Q_ASSERT(context);
m_funcs = context->functions();
Q_ASSERT(m_funcs);
+ m_isES3 = context->format().majorVersion() >= 3;
}
void QGraphicsHelperES2::drawElementsInstanced(GLenum primitiveType,
@@ -367,6 +385,21 @@ void QGraphicsHelperES2::bindUniform(const QVariant &v, const ShaderUniform &des
break;
}
+ // ES 3.0+
+ case GL_SAMPLER_3D:
+ case GL_SAMPLER_2D_SHADOW:
+ case GL_SAMPLER_CUBE_SHADOW:
+ case GL_SAMPLER_2D_ARRAY:
+ case GL_SAMPLER_2D_ARRAY_SHADOW:
+ if (m_isES3) {
+ Q_ASSERT(description.m_size == 1);
+ m_funcs->glUniform1i(description.m_location, v.toInt());
+ } else {
+ qWarning() << Q_FUNC_INFO << "ES 3.0 uniform type" << description.m_type << "for"
+ << description.m_name << "is not supported in ES 2.0";
+ }
+ break;
+
default:
qWarning() << Q_FUNC_INFO << "unsupported uniform type:" << description.m_type << "for " << description.m_name;
break;
diff --git a/src/render/backend/qgraphicshelperes2_p.h b/src/render/backend/qgraphicshelperes2_p.h
index 7cd58a016..200242578 100644
--- a/src/render/backend/qgraphicshelperes2_p.h
+++ b/src/render/backend/qgraphicshelperes2_p.h
@@ -89,6 +89,7 @@ public:
private:
QOpenGLFunctions *m_funcs;
+ bool m_isES3;
};
} // Render