diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-08-07 10:38:18 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2015-08-07 09:26:21 +0000 |
commit | 061a12095192e766d92c8ba41915e3cd5eeadaef (patch) | |
tree | f7c8513b3966d15a6a0e81e62886e969b7d6a8d9 /src | |
parent | 03811c1729cf5ddec63ce3e288bf132abcc40c27 (diff) |
Fix Scene3D for 3.2+ core profiles
Change-Id: I96b68488f4084085307f32829a2dd85777e4d750
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick3d/imports/scene3d/scene3ditem.cpp | 62 |
1 files changed, 45 insertions, 17 deletions
diff --git a/src/quick3d/imports/scene3d/scene3ditem.cpp b/src/quick3d/imports/scene3d/scene3ditem.cpp index 6fc49f98a..c89a8bbe9 100644 --- a/src/quick3d/imports/scene3d/scene3ditem.cpp +++ b/src/quick3d/imports/scene3d/scene3ditem.cpp @@ -288,27 +288,55 @@ public: protected: const char *vertexShader() const Q_DECL_FINAL { - return "" - "uniform highp mat4 qt_Matrix; \n" - "attribute highp vec4 qt_VertexPosition; \n" - "attribute highp vec2 qt_VertexTexCoord; \n" - "varying highp vec2 qt_TexCoord; \n" - "void main() { \n" - " qt_TexCoord = qt_VertexTexCoord; \n" - " gl_Position = qt_Matrix * qt_VertexPosition; \n" - "}"; + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (ctx->format().version() >= qMakePair(3, 2) && ctx->format().profile() == QSurfaceFormat::CoreProfile) { + return "" + "#version 150 core \n" + "uniform mat4 qt_Matrix; \n" + "in vec4 qt_VertexPosition; \n" + "in vec2 qt_VertexTexCoord; \n" + "out vec2 qt_TexCoord; \n" + "void main() { \n" + " qt_TexCoord = qt_VertexTexCoord; \n" + " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}"; + } else { + return "" + "uniform highp mat4 qt_Matrix; \n" + "in highp vec4 qt_VertexPosition; \n" + "in highp vec2 qt_VertexTexCoord; \n" + "out highp vec2 qt_TexCoord; \n" + "void main() { \n" + " qt_TexCoord = qt_VertexTexCoord; \n" + " gl_Position = qt_Matrix * qt_VertexPosition; \n" + "}"; + } } const char *fragmentShader() const Q_DECL_FINAL { - return "" - "uniform highp sampler2D source; \n" - "uniform highp float qt_Opacity; \n" - "varying highp vec2 qt_TexCoord; \n" - "void main() { \n" - " highp vec4 p = texture2D(source, qt_TexCoord); \n" - " gl_FragColor = vec4(p.rgb * p.a, qt_Opacity * p.a); \n" - "}"; + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + if (ctx->format().version() >= qMakePair(3, 2) && ctx->format().profile() == QSurfaceFormat::CoreProfile) { + return "" + "#version 150 core \n" + "uniform sampler2D source; \n" + "uniform float qt_Opacity; \n" + "in vec2 qt_TexCoord; \n" + "out vec4 fragColor; \n" + "void main() { \n" + " vec4 p = texture(source, qt_TexCoord); \n" + " fragColor = vec4(p.rgb * p.a, qt_Opacity * p.a); \n" + "}"; + } else { + return "" + "uniform highp sampler2D source; \n" + "uniform highp float qt_Opacity; \n" + "varying highp vec2 qt_TexCoord; \n" + "void main() { \n" + " highp vec4 p = texture2D(source, qt_TexCoord); \n" + " gl_FragColor = vec4(p.rgb * p.a, qt_Opacity * p.a); \n" + "}"; + } } void initialize() Q_DECL_FINAL |