summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgraphicsshadereffect.cpp
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-09-03 14:02:13 +0200
committerCristian Maureira-Fredes <cristian.maureira-fredes@qt.io>2018-10-15 10:55:18 +0000
commit1f6bfc220774e9407fe88916843b76ed103cff72 (patch)
tree8d6157d5b974e6045d75a716f8eb0db4daefa35f /src/opengl/qgraphicsshadereffect.cpp
parent02a214442781bf112c1cc85d2470c6fcec8ed207 (diff)
Doc: Move literal code block to a separate file
We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/opengl/qgraphicsshadereffect.cpp')
-rw-r--r--src/opengl/qgraphicsshadereffect.cpp46
1 files changed, 3 insertions, 43 deletions
diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp
index cf3d307d71..97b83a6b3d 100644
--- a/src/opengl/qgraphicsshadereffect.cpp
+++ b/src/opengl/qgraphicsshadereffect.cpp
@@ -70,48 +70,12 @@ QT_BEGIN_NAMESPACE
grayscale and then applies a colorize operation using the
\c effectColor value:
- \code
- static char const colorizeShaderCode[] =
- "uniform lowp vec4 effectColor;\n"
- "lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) {\n"
- " vec4 src = texture2D(imageTexture, textureCoords);\n"
- " float gray = dot(src.rgb, vec3(0.212671, 0.715160, 0.072169));\n"
- " vec4 colorize = 1.0-((1.0-gray)*(1.0-effectColor));\n"
- " return vec4(colorize.rgb, src.a);\n"
- "}";
- \endcode
+ \snippet code/src_opengl_qgraphicsshadereffect.cpp 0
To use this shader code, it is necessary to define a subclass
of QGraphicsShaderEffect as follows:
- \code
- class ColorizeEffect : public QGraphicsShaderEffect
- {
- Q_OBJECT
- public:
- ColorizeEffect(QObject *parent = 0)
- : QGraphicsShaderEffect(parent), color(Qt::black)
- {
- setPixelShaderFragment(colorizeShaderCode);
- }
-
- QColor effectColor() const { return color; }
- void setEffectColor(const QColor& c)
- {
- color = c;
- setUniformsDirty();
- }
-
- protected:
- void setUniforms(QGLShaderProgram *program)
- {
- program->setUniformValue("effectColor", color);
- }
-
- private:
- QColor color;
- };
- \endcode
+ \snippet code/src_opengl_qgraphicsshadereffect.cpp 1
The setUniforms() function is called when the effect is about
to be used for drawing to give the subclass the opportunity to
@@ -216,11 +180,7 @@ QByteArray QGraphicsShaderEffect::pixelShaderFragment() const
shader program. The following is the default pixel shader fragment,
which draws a pixmap with no effect applied:
- \code
- lowp vec4 customShader(lowp sampler2D imageTexture, highp vec2 textureCoords) {
- return texture2D(imageTexture, textureCoords);
- }
- \endcode
+ \snippet code/src_opengl_qgraphicsshadereffect.cpp 2
\sa pixelShaderFragment(), setUniforms()
*/