summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-26 17:32:33 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-28 18:00:44 +0100
commit5119bbc6424742860abafe7a371fa5234f03eabb (patch)
tree0e6aa1e0380975c00e9aadd8b46d4623b0233b2d /src/gui/opengl
parent1219dbe543eb91a52645cd96e6b7eccfd60b5be7 (diff)
Add core profile versions of the glyph cache shaders
The last step to make QOpenGLTextureGlyphCache working with OpenGL core profiles. [ChangeLog] Native (that is, not distance field based) text rendering is now functional on OpenGL 3.2+ core profiles too. Task-number: QTBUG-36993 Change-Id: Ic6c0db4806cea623ca7a19ab77b0329155824877 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopenglengineshadersource_p.h35
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp9
2 files changed, 40 insertions, 4 deletions
diff --git a/src/gui/opengl/qopenglengineshadersource_p.h b/src/gui/opengl/qopenglengineshadersource_p.h
index 5bb0bc4704..02a23193a8 100644
--- a/src/gui/opengl/qopenglengineshadersource_p.h
+++ b/src/gui/opengl/qopenglengineshadersource_p.h
@@ -517,6 +517,41 @@ static const char* const qopenglslRgbMaskFragmentShaderPass2 = "\n\
ExclusionCompositionModeFragmentShader,
*/
+// OpenGL 3.2 core profile versions of shaders that are used by QOpenGLTextureGlyphCache
+
+static const char* const qopenglslMainWithTexCoordsVertexShader_core = "#version 150 core \n\
+ in vec2 textureCoordArray; \n\
+ out vec2 textureCoords; \n\
+ void setPosition(); \n\
+ void main(void) \n\
+ { \n\
+ setPosition(); \n\
+ textureCoords = textureCoordArray; \n\
+ }\n";
+
+static const char* const qopenglslUntransformedPositionVertexShader_core = "\n\
+ in vec4 vertexCoordsArray; \n\
+ void setPosition(void) \n\
+ { \n\
+ gl_Position = vertexCoordsArray; \n\
+ }\n";
+
+static const char* const qopenglslMainFragmentShader_core = "#version 150 core \n\
+ vec4 srcPixel(); \n\
+ out vec4 fragColor; \n\
+ void main() \n\
+ { \n\
+ fragColor = srcPixel(); \n\
+ }\n";
+
+static const char* const qopenglslImageSrcFragmentShader_core = "\n\
+ in vec2 textureCoords; \n\
+ uniform sampler2D imageTexture; \n\
+ vec4 srcPixel() \n\
+ { \n"
+ "return texture(imageTexture, textureCoords); \n"
+ "}\n";
+
QT_END_NAMESPACE
#endif // GLGC_SHADER_SOURCE_H
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index 3524c1cb1a..356f68b49b 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -248,11 +248,12 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
if (pex == 0) {
if (m_blitProgram == 0) {
m_blitProgram = new QOpenGLShaderProgram(ctx);
+ const bool isCoreProfile = ctx->format().profile() == QSurfaceFormat::CoreProfile;
{
QString source;
- source.append(QLatin1String(qopenglslMainWithTexCoordsVertexShader));
- source.append(QLatin1String(qopenglslUntransformedPositionVertexShader));
+ source.append(QLatin1String(isCoreProfile ? qopenglslMainWithTexCoordsVertexShader_core : qopenglslMainWithTexCoordsVertexShader));
+ source.append(QLatin1String(isCoreProfile ? qopenglslUntransformedPositionVertexShader_core : qopenglslUntransformedPositionVertexShader));
QOpenGLShader *vertexShader = new QOpenGLShader(QOpenGLShader::Vertex, m_blitProgram);
vertexShader->compileSourceCode(source);
@@ -262,8 +263,8 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
{
QString source;
- source.append(QLatin1String(qopenglslMainFragmentShader));
- source.append(QLatin1String(qopenglslImageSrcFragmentShader));
+ source.append(QLatin1String(isCoreProfile ? qopenglslMainFragmentShader_core : qopenglslMainFragmentShader));
+ source.append(QLatin1String(isCoreProfile ? qopenglslImageSrcFragmentShader_core : qopenglslImageSrcFragmentShader));
QOpenGLShader *fragmentShader = new QOpenGLShader(QOpenGLShader::Fragment, m_blitProgram);
fragmentShader->compileSourceCode(source);