diff options
author | Sean Harmer <[email protected]> | 2013-10-19 14:21:31 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2013-10-21 19:10:50 +0200 |
commit | de31a57672ec461c2081f65e3631134ee45de887 (patch) | |
tree | 98678959c8af0bc36629c97ecf0c2ede77e05db2 /src | |
parent | a3f01331263eddbc502fb88734568ac38df5e316 (diff) |
Don't use reserved keyword "texture" as uniform variable name
The "texture" keyword is a function name in OpenGL core profile. This
commit is in preparation for making the Qt Quick 2 renderer and
materials work with a core profile context.
Change-Id: Iad243e64ab8db739fc46b85bb626bdb8b9ceb208
Reviewed-by: James Turner <[email protected]>
Reviewed-by: Gunnar Sletta <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/particles/qquickimageparticle.cpp | 22 | ||||
-rw-r--r-- | src/quick/items/qquickanimatedsprite.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquickspritesequence.cpp | 4 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdefaultglyphnode_p.cpp | 36 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp | 78 | ||||
-rw-r--r-- | src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp | 2 |
6 files changed, 73 insertions, 73 deletions
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index c550ef8f20..fa828d7b63 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -204,7 +204,7 @@ static const char vertexShaderCode[] = "}\n"; static const char fragmentShaderCode[] = - "uniform sampler2D texture;\n" + "uniform sampler2D _qt_texture;\n" "uniform lowp float qt_Opacity;\n" "\n" "#if defined(SPRITE)\n" @@ -224,21 +224,21 @@ static const char fragmentShaderCode[] = "\n" "void main() {\n" "#if defined(SPRITE)\n" - " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), tt.y)\n" + " gl_FragColor = mix(texture2D(_qt_texture, fTexS.xy), texture2D(_qt_texture, fTexS.zw), tt.y)\n" " * fColor\n" " * texture2D(colortable, tt)\n" " * qt_Opacity;\n" "#elif defined(TABLE)\n" - " gl_FragColor = texture2D(texture, fTex)\n" + " gl_FragColor = texture2D(_qt_texture, fTex)\n" " * fColor\n" " * texture2D(colortable, tt)\n" " * qt_Opacity;\n" "#elif defined(DEFORM)\n" - " gl_FragColor = (texture2D(texture, fTex)) * fColor * qt_Opacity;\n" + " gl_FragColor = (texture2D(_qt_texture, fTex)) * fColor * qt_Opacity;\n" "#elif defined(COLOR)\n" - " gl_FragColor = (texture2D(texture, gl_PointCoord)) * fColor * qt_Opacity;\n" + " gl_FragColor = (texture2D(_qt_texture, gl_PointCoord)) * fColor * qt_Opacity;\n" "#else\n" - " gl_FragColor = texture2D(texture, gl_PointCoord) * (fFade * qt_Opacity);\n" + " gl_FragColor = texture2D(_qt_texture, gl_PointCoord) * (fFade * qt_Opacity);\n" "#endif\n" "}\n"; @@ -296,7 +296,7 @@ public: void initialize() { QSGSimpleMaterialShader<TabledMaterialData>::initialize(); program()->bind(); - program()->setUniformValue("texture", 0); + program()->setUniformValue("_qt_texture", 0); program()->setUniformValue("colortable", 1); glFuncs = QOpenGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); @@ -358,7 +358,7 @@ public: void initialize() { QSGSimpleMaterialShader<DeformableMaterialData>::initialize(); program()->bind(); - program()->setUniformValue("texture", 0); + program()->setUniformValue("_qt_texture", 0); glFuncs = QOpenGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); m_entry_id = program()->uniformLocation("entry"); @@ -409,7 +409,7 @@ public: void initialize() { QSGSimpleMaterialShader<SpriteMaterialData>::initialize(); program()->bind(); - program()->setUniformValue("texture", 0); + program()->setUniformValue("_qt_texture", 0); program()->setUniformValue("colortable", 1); glFuncs = QOpenGLContext::currentContext()->functions(); //Don't actually expose the animSheetSize in the shader, it's currently only used for CPU calculations. @@ -488,7 +488,7 @@ public: void initialize() { QSGSimpleMaterialShader<ColoredMaterialData>::initialize(); program()->bind(); - program()->setUniformValue("texture", 0); + program()->setUniformValue("_qt_texture", 0); glFuncs = QOpenGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); m_entry_id = program()->uniformLocation("entry"); @@ -552,7 +552,7 @@ public: void initialize() { QSGSimpleMaterialShader<SimpleMaterialData>::initialize(); program()->bind(); - program()->setUniformValue("texture", 0); + program()->setUniformValue("_qt_texture", 0); glFuncs = QOpenGLContext::currentContext()->functions(); m_timestamp_id = program()->uniformLocation("timestamp"); m_entry_id = program()->uniformLocation("entry"); diff --git a/src/quick/items/qquickanimatedsprite.cpp b/src/quick/items/qquickanimatedsprite.cpp index 3a32169447..846de15581 100644 --- a/src/quick/items/qquickanimatedsprite.cpp +++ b/src/quick/items/qquickanimatedsprite.cpp @@ -80,14 +80,14 @@ static const char vertexShaderCode[] = "}\n"; static const char fragmentShaderCode[] = - "uniform sampler2D texture;\n" + "uniform sampler2D _qt_texture;\n" "uniform lowp float qt_Opacity;\n" "\n" "varying highp vec4 fTexS;\n" "varying lowp float progress;\n" "\n" "void main() {\n" - " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" + " gl_FragColor = mix(texture2D(_qt_texture, fTexS.xy), texture2D(_qt_texture, fTexS.zw), progress) * qt_Opacity;\n" "}\n"; class QQuickAnimatedSpriteMaterial : public QSGMaterial diff --git a/src/quick/items/qquickspritesequence.cpp b/src/quick/items/qquickspritesequence.cpp index 3b2b3269e2..3c1492e0b3 100644 --- a/src/quick/items/qquickspritesequence.cpp +++ b/src/quick/items/qquickspritesequence.cpp @@ -79,14 +79,14 @@ static const char vertexShaderCode[] = "}\n"; static const char fragmentShaderCode[] = - "uniform sampler2D texture;\n" + "uniform sampler2D _qt_texture;\n" "uniform lowp float qt_Opacity;\n" "\n" "varying highp vec4 fTexS;\n" "varying lowp float progress;\n" "\n" "void main() {\n" - " gl_FragColor = mix(texture2D(texture, fTexS.xy), texture2D(texture, fTexS.zw), progress) * qt_Opacity;\n" + " gl_FragColor = mix(texture2D(_qt_texture, fTexS.xy), texture2D(_qt_texture, fTexS.zw), progress) * qt_Opacity;\n" "}\n"; class QQuickSpriteSequenceMaterial : public QSGMaterial diff --git a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp index 50009d7709..39d9832f58 100644 --- a/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdefaultglyphnode_p.cpp @@ -101,10 +101,10 @@ const char *QSGTextMaskShader::vertexShader() const { const char *QSGTextMaskShader::fragmentShader() const { return "varying highp vec2 sampleCoord; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "void main() { \n" - " lowp vec4 glyph = texture2D(texture, sampleCoord); \n" + " lowp vec4 glyph = texture2D(_qt_texture, sampleCoord); \n" " gl_FragColor = vec4(glyph.rgb * color.a, glyph.a); \n" "}"; } @@ -389,14 +389,14 @@ const char *QSGStyledTextShader::fragmentShader() const return "varying highp vec2 sampleCoord; \n" "varying highp vec2 shiftedSampleCoord; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "uniform lowp vec4 styleColor; \n" - "void main() { \n" - " lowp float glyph = texture2D(texture, sampleCoord).a; \n" - " lowp float style = clamp(texture2D(texture, shiftedSampleCoord).a - glyph, \n" - " 0.0, 1.0); \n" - " gl_FragColor = style * styleColor + glyph * color; \n" + "void main() { \n" + " lowp float glyph = texture2D(_qt_texture, sampleCoord).a; \n" + " lowp float style = clamp(texture2D(_qt_texture, shiftedSampleCoord).a - glyph, \n" + " 0.0, 1.0); \n" + " gl_FragColor = style * styleColor + glyph * color; \n" "}"; } @@ -444,18 +444,18 @@ const char *QSGOutlinedTextShader::fragmentShader() const "varying highp vec2 sCoordDown; \n" "varying highp vec2 sCoordLeft; \n" "varying highp vec2 sCoordRight; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "uniform lowp vec4 styleColor; \n" - "void main() { \n" - "lowp float glyph = texture2D(texture, sampleCoord).a; \n" - " lowp float outline = clamp(clamp(texture2D(texture, sCoordUp).a + \n" - " texture2D(texture, sCoordDown).a + \n" - " texture2D(texture, sCoordLeft).a + \n" - " texture2D(texture, sCoordRight).a, \n" - " 0.0, 1.0) - glyph, \n" - " 0.0, 1.0); \n" - " gl_FragColor = outline * styleColor + glyph * color; \n" + "void main() { \n" + "lowp float glyph = texture2D(_qt_texture, sampleCoord).a; \n" + " lowp float outline = clamp(clamp(texture2D(_qt_texture, sCoordUp).a + \n" + " texture2D(_qt_texture, sCoordDown).a + \n" + " texture2D(_qt_texture, sCoordLeft).a + \n" + " texture2D(_qt_texture, sCoordRight).a, \n" + " 0.0, 1.0) - glyph, \n" + " 0.0, 1.0); \n" + " gl_FragColor = outline * styleColor + glyph * color; \n" "}"; } diff --git a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp index 0cf7abed2e..125243847a 100644 --- a/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp +++ b/src/quick/scenegraph/qsgdistancefieldglyphnode_p.cpp @@ -96,15 +96,15 @@ const char *QSGDistanceFieldTextMaterialShader::vertexShader() const { const char *QSGDistanceFieldTextMaterialShader::fragmentShader() const { return - "varying highp vec2 sampleCoord; \n" - "uniform mediump sampler2D texture; \n" - "uniform lowp vec4 color; \n" - "uniform mediump float alphaMin; \n" - "uniform mediump float alphaMax; \n" - "void main() { \n" - " gl_FragColor = color * smoothstep(alphaMin, \n" - " alphaMax, \n" - " texture2D(texture, sampleCoord).a); \n" + "varying highp vec2 sampleCoord; \n" + "uniform mediump sampler2D _qt_texture; \n" + "uniform lowp vec4 color; \n" + "uniform mediump float alphaMin; \n" + "uniform mediump float alphaMax; \n" + "void main() { \n" + " gl_FragColor = color * smoothstep(alphaMin, \n" + " alphaMax, \n" + " texture2D(_qt_texture, sampleCoord).a); \n" "}"; } @@ -366,7 +366,7 @@ protected: const char *DistanceFieldOutlineTextMaterialShader::fragmentShader() const { return "varying highp vec2 sampleCoord; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "uniform lowp vec4 styleColor; \n" "uniform mediump float alphaMin; \n" @@ -374,7 +374,7 @@ const char *DistanceFieldOutlineTextMaterialShader::fragmentShader() const { "uniform mediump float outlineAlphaMax0; \n" "uniform mediump float outlineAlphaMax1; \n" "void main() { \n" - " mediump float d = texture2D(texture, sampleCoord).a; \n" + " mediump float d = texture2D(_qt_texture, sampleCoord).a; \n" " gl_FragColor = mix(styleColor, color, smoothstep(alphaMin, alphaMax, d)) \n" " * smoothstep(outlineAlphaMax0, outlineAlphaMax1, d); \n" "}"; @@ -514,19 +514,19 @@ const char *DistanceFieldShiftedStyleTextMaterialShader::vertexShader() const const char *DistanceFieldShiftedStyleTextMaterialShader::fragmentShader() const { return - "varying highp vec2 sampleCoord; \n" - "varying highp vec2 shiftedSampleCoord; \n" - "uniform sampler2D texture; \n" - "uniform lowp vec4 color; \n" - "uniform lowp vec4 styleColor; \n" - "uniform mediump float alphaMin; \n" - "uniform mediump float alphaMax; \n" - "void main() { \n" - " highp float a = smoothstep(alphaMin, alphaMax, texture2D(texture, sampleCoord).a);\n" - " highp vec4 shifted = styleColor * smoothstep(alphaMin, \n" - " alphaMax, \n" - " texture2D(texture, shiftedSampleCoord).a); \n" - " gl_FragColor = mix(shifted, color, a); \n" + "varying highp vec2 sampleCoord; \n" + "varying highp vec2 shiftedSampleCoord; \n" + "uniform sampler2D _qt_texture; \n" + "uniform lowp vec4 color; \n" + "uniform lowp vec4 styleColor; \n" + "uniform mediump float alphaMin; \n" + "uniform mediump float alphaMax; \n" + "void main() { \n" + " highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a); \n" + " highp vec4 shifted = styleColor * smoothstep(alphaMin, \n" + " alphaMax, \n" + " texture2D(_qt_texture, shiftedSampleCoord).a); \n" + " gl_FragColor = mix(shifted, color, a); \n" "}"; } @@ -607,17 +607,17 @@ const char *QSGHiQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons "varying highp vec3 sampleNearLeft; \n" "varying highp vec3 sampleNearRight; \n" "varying highp vec3 sampleFarRight; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "uniform mediump float alphaMin; \n" "uniform mediump float alphaMax; \n" "void main() { \n" " highp vec4 n; \n" - " n.x = texture2DProj(texture, sampleFarLeft).a; \n" - " n.y = texture2DProj(texture, sampleNearLeft).a; \n" - " highp float c = texture2D(texture, sampleCoord).a; \n" - " n.z = texture2DProj(texture, sampleNearRight).a; \n" - " n.w = texture2DProj(texture, sampleFarRight).a; \n" + " n.x = texture2DProj(_qt_texture, sampleFarLeft).a; \n" + " n.y = texture2DProj(_qt_texture, sampleNearLeft).a; \n" + " highp float c = texture2D(_qt_texture, sampleCoord).a; \n" + " n.z = texture2DProj(_qt_texture, sampleNearRight).a; \n" + " n.w = texture2DProj(_qt_texture, sampleFarRight).a; \n" #if 0 // Blurrier, faster. " n = smoothstep(alphaMin, alphaMax, n); \n" @@ -638,18 +638,18 @@ const char *QSGHiQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons // return // "#extension GL_OES_standard_derivatives: enable \n" // "varying highp vec2 sampleCoord; \n" -// "uniform sampler2D texture; \n" +// "uniform sampler2D _qt_texture; \n" // "uniform lowp vec4 color; \n" // "uniform highp float alphaMin; \n" // "uniform highp float alphaMax; \n" // "void main() { \n" // " highp vec2 delta = dFdx(sampleCoord); \n" // " highp vec4 n; \n" -// " n.x = texture2D(texture, sampleCoord - 0.667 * delta).a; \n" -// " n.y = texture2D(texture, sampleCoord - 0.333 * delta).a; \n" -// " highp float c = texture2D(texture, sampleCoord).a; \n" -// " n.z = texture2D(texture, sampleCoord + 0.333 * delta).a; \n" -// " n.w = texture2D(texture, sampleCoord + 0.667 * delta).a; \n" +// " n.x = texture2D(_qt_texture, sampleCoord - 0.667 * delta).a; \n" +// " n.y = texture2D(_qt_texture, sampleCoord - 0.333 * delta).a; \n" +// " highp float c = texture2D(_qt_texture, sampleCoord).a; \n" +// " n.z = texture2D(_qt_texture, sampleCoord + 0.333 * delta).a; \n" +// " n.w = texture2D(_qt_texture, sampleCoord + 0.667 * delta).a; \n" // " n = smoothstep(alphaMin, alphaMax, n); \n" // " c = smoothstep(alphaMin, alphaMax, c); \n" // " gl_FragColor = vec4(0.333 * (n.xyz + n.yzw + c), c) * color.w; \n" @@ -746,14 +746,14 @@ const char *QSGLoQSubPixelDistanceFieldTextMaterialShader::fragmentShader() cons return "varying highp vec3 sampleNearLeft; \n" "varying highp vec3 sampleNearRight; \n" - "uniform sampler2D texture; \n" + "uniform sampler2D _qt_texture; \n" "uniform lowp vec4 color; \n" "uniform mediump float alphaMin; \n" "uniform mediump float alphaMax; \n" "void main() { \n" " highp vec2 n; \n" - " n.x = texture2DProj(texture, sampleNearLeft).a; \n" - " n.y = texture2DProj(texture, sampleNearRight).a; \n" + " n.x = texture2DProj(_qt_texture, sampleNearLeft).a; \n" + " n.y = texture2DProj(_qt_texture, sampleNearRight).a; \n" " n = smoothstep(alphaMin, alphaMax, n); \n" " highp float c = 0.5 * (n.x + n.y); \n" " gl_FragColor = vec4(n.x, c, n.y, c) * color.w; \n" diff --git a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp index fb9eebf403..34a884348d 100644 --- a/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp +++ b/src/quick/scenegraph/qsgshareddistancefieldglyphcache.cpp @@ -531,7 +531,7 @@ void QSGSharedDistanceFieldGlyphCache::saveTexture(GLuint textureId, int width, glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); - int textureUniformLocation = glGetUniformLocation(shaderProgram, "texture"); + int textureUniformLocation = glGetUniformLocation(shaderProgram, "_qt_texture"); glUniform1i(textureUniformLocation, 0); } |