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>
This commit is contained in:
parent
1219dbe543
commit
5119bbc642
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user